API Reference

template<typename EnumType>
struct _eat_assign
#include <enum.h>

Get intrinsic value of an (Enum::value) by taking advantage of.

Public Functions

inline explicit BETTER_ENUMS_CONSTEXPR_ _eat_assign(EnumType value)
template<typename Any> inline BETTER_ENUMS_CONSTEXPR_ const _eat_assign & operator= (Any) const
inline BETTER_ENUMS_CONSTEXPR_ operator EnumType() const

Private Members

EnumType _value
template<typename Enum>
struct _initialize_at_program_start

Public Functions

inline _initialize_at_program_start()
template<typename Element>
struct _iterable

Public Types

typedef const Element *iterator

Public Functions

inline BETTER_ENUMS_CONSTEXPR_ iterator begin () const
inline BETTER_ENUMS_CONSTEXPR_ iterator end () const
inline BETTER_ENUMS_CONSTEXPR_ std::size_t size () const
inline BETTER_ENUMS_CONSTEXPR_ const Element & operator[] (std::size_t index) const
inline BETTER_ENUMS_CONSTEXPR_ _iterable(const Element *array, std::size_t s)

Private Members

const Element *const _array
const std::size_t _size
class Acrobot : public rlenvscpp::envs::gymnasium::GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateDiscreteActionEnv<6, 2, 0, real_t>>
#include <acrobot_env.h>

The CartPole class Interface for CartPole environment.

Public Types

typedef GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateDiscreteActionEnv<6, 2, 0, real_t>>::base_type base_type

Base class type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

Public Functions

Acrobot(const RESTApiServerWrapper &api_server)

Acrobot. Constructor.

Acrobot(const RESTApiServerWrapper &api_server, const uint_t cidx)

CartPole. Constructor.

Acrobot(const Acrobot &other)

copy ctor

~Acrobot() = default

~Acrobot. Destructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any>&) final override

make. Build the environment

virtual time_step_type step(const action_type &action) final override

step. Step in the environment following the given action

Acrobot make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

Public Static Attributes

static const std::string name = "Acrobot"

name

static const std::string URI = "/gymnasium/acrobot-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

Handle the reset response from the environment server.

class AcrobotV : public rlenvscpp::envs::gymnasium::GymnasiumVecEnvBase<VectorTimeStep<detail_::AcrobotVEnv::state_type>, detail_::AcrobotVEnv>
#include <acrobot_vec_env.h>

The CartPole class Interface for CartPole environment.

Public Types

typedef GymnasiumVecEnvBase<VectorTimeStep<detail_::AcrobotVEnv::state_type>, detail_::AcrobotVEnv>::base_type base_type

Base class type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

Public Functions

AcrobotV(const RESTApiServerWrapper &api_server)

Acrobot. Constructor.

AcrobotV(const RESTApiServerWrapper &api_server, const uint_t cidx)

CartPole. Constructor.

AcrobotV(const AcrobotV &other)

copy ctor

~AcrobotV() = default

~Acrobot. Destructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any>&) final override

make. Build the environment

virtual time_step_type step(const action_type &action) final override

step. Step in the environment following the given action

AcrobotV make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

Public Static Attributes

static const std::string name = "AcrobotV"

name

static const std::string URI = "/gymnasium/acrobot-env/v"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

Handle the reset response from the environment server.

struct AcrobotVEnv

Public Types

typedef ContinuousVectorSpace<6, real_t> state_space
typedef state_space::space_item_type state_type
typedef ScalarDiscreteSpace<0, 3> action_space
typedef std::vector<typename action_space::space_item_type> action_type

the Action type

Public Static Attributes

static constexpr uint_t STATE_SPACE_SIZE = state_space::size

state space size

static constexpr uint_t ACTION_SPACE_SIZE = action_space::size

state space size

template<typename BasicJsonType>
struct actual_object_comparator

Public Types

using object_t = typename BasicJsonType::object_t
using object_comparator_t = typename BasicJsonType::default_object_comparator_t
using type = typename std::conditional<has_key_compare<object_t>::value, typename object_t::key_compare, object_comparator_t>::type
template<typename ValueType, typename>
struct adl_serializer
#include <json.hpp>

namespace for Niels Lohmann

default JSONSerializer template argument

Since

version 1.0.0

This serializer ignores the template arguments and uses ADL (argument-dependent lookup) for serialization.

Public Static Functions

template<typename BasicJsonType, typename TargetType = ValueType>
static inline auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val))) -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())

convert a JSON value to any value type

template<typename BasicJsonType, typename TargetType = ValueType>
static inline auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType>{}))) -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType>{}))

convert a JSON value to any value type

template<typename BasicJsonType, typename TargetType = ValueType>
static inline auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val)))) -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())

convert any value type to a JSON value

template<template<typename U, typename V, typename ...Args> class ObjectType = std::map, template<typename U, typename ...Args> class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template<typename U> class AllocatorType = std::allocator, template<typename T, typename SFINAE = void> class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>, class CustomBaseClass = void>
class basic_json : public nlohmann::detail::json_base_class<void>
#include <json.hpp>

namespace for Niels Lohmann

a class to store JSON values

a class to store JSON values

Since

version 1.0.0

Since

version 1.0.0

element access

Access to the JSON value.

template<typename KeyType>
using is_comparable_with_object_key = detail::is_comparable<object_comparator_t, const typename object_t::key_type&, KeyType>
template<typename ValueType>
using value_return_type = std::conditional<detail::is_c_string_uncvref<ValueType>::value, string_t, typename std::decay<ValueType>::type>
template<typename KeyType, detail::enable_if_t<detail::has_erase_with_key_type<basic_json_t, KeyType>::value, int> = 0>
inline size_type erase_internal(KeyType &&key)
template<typename KeyType, detail::enable_if_t<!detail::has_erase_with_key_type<basic_json_t, KeyType>::value, int> = 0>
inline size_type erase_internal(KeyType &&key)
inline reference at(size_type idx)

access specified array element with bounds checking

inline const_reference at(size_type idx) const

access specified array element with bounds checking

inline reference at(const typename object_t::key_type &key)

access specified object element with bounds checking

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline reference at(KeyType &&key)

access specified object element with bounds checking

inline const_reference at(const typename object_t::key_type &key) const

access specified object element with bounds checking

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline const_reference at(KeyType &&key) const

access specified object element with bounds checking

inline reference operator[](size_type idx)

access specified array element

inline const_reference operator[](size_type idx) const

access specified array element

inline reference operator[](typename object_t::key_type key)

access specified object element

inline const_reference operator[](const typename object_t::key_type &key) const

access specified object element

template<typename T>
inline reference operator[](T *key)
template<typename T>
inline const_reference operator[](T *key) const
template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline reference operator[](KeyType &&key)

access specified object element

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline const_reference operator[](KeyType &&key) const

access specified object element

template<class ValueType, detail::enable_if_t<!detail::is_transparent<object_comparator_t>::value && detail::is_getable<basic_json_t, ValueType>::value && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int> = 0>
inline ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const

access specified object element with default value

template<class ValueType, class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t<!detail::is_transparent<object_comparator_t>::value && detail::is_getable<basic_json_t, ReturnType>::value && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int> = 0>
inline ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const

access specified object element with default value

template<class ValueType, class KeyType, detail::enable_if_t<detail::is_transparent<object_comparator_t>::value && !detail::is_json_pointer<KeyType>::value && is_comparable_with_object_key<KeyType>::value && detail::is_getable<basic_json_t, ValueType>::value && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int> = 0>
inline ValueType value(KeyType &&key, const ValueType &default_value) const

access specified object element with default value

template<class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t<detail::is_transparent<object_comparator_t>::value && !detail::is_json_pointer<KeyType>::value && is_comparable_with_object_key<KeyType>::value && detail::is_getable<basic_json_t, ReturnType>::value && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int> = 0>
inline ReturnType value(KeyType &&key, ValueType &&default_value) const

access specified object element via JSON Pointer with default value

template<class ValueType, detail::enable_if_t<detail::is_getable<basic_json_t, ValueType>::value && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int> = 0>
inline ValueType value(const json_pointer &ptr, const ValueType &default_value) const

access specified object element via JSON Pointer with default value

template<class ValueType, class ReturnType = typename value_return_type<ValueType>::type, detail::enable_if_t<detail::is_getable<basic_json_t, ReturnType>::value && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value, int> = 0>
inline ReturnType value(const json_pointer &ptr, ValueType &&default_value) const

access specified object element via JSON Pointer with default value

template<class ValueType, class BasicJsonType, detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value &&detail::is_getable< basic_json_t, ValueType >::value &&!std::is_same< value_t, detail::uncvref_t< ValueType >>::value, int > = 0> inline  JSON_HEDLEY_DEPRECATED_FOR (3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) ValueType value(const

access the first element

inline const_reference front() const

access the first element

inline reference back()

access the last element

inline const_reference back() const

access the last element

template<class IteratorType, detail::enable_if_t<std::is_same<IteratorType, typename basic_json_t::iterator>::value || std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int> = 0>
inline IteratorType erase(IteratorType pos)

remove element given an iterator

template<class IteratorType, detail::enable_if_t<std::is_same<IteratorType, typename basic_json_t::iterator>::value || std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int> = 0>
inline IteratorType erase(IteratorType first, IteratorType last)

remove elements given an iterator range

inline size_type erase(const typename object_t::key_type &key)

remove element from a JSON object given a key

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline size_type erase(KeyType &&key)

remove element from a JSON object given a key

inline void erase(const size_type idx)

remove element from a JSON array given an index

exceptions

Classes to implement user-defined exceptions.

using exception = detail::exception
using parse_error = detail::parse_error
using invalid_iterator = detail::invalid_iterator
using type_error = detail::type_error
using out_of_range = detail::out_of_range
using other_error = detail::other_error

container types

The canonic container types to use basic_json like any other STL container.

using value_type = basic_json

the type of elements in a basic_json container

using reference = value_type&

the type of an element reference

using const_reference = const value_type&

the type of an element const reference

using difference_type = std::ptrdiff_t

a type to represent differences between iterators

using size_type = std::size_t

a type to represent container sizes

using allocator_type = AllocatorType<basic_json>

the allocator type

using pointer = typename std::allocator_traits<allocator_type>::pointer

the type of an element pointer

using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer

the type of an element const pointer

using iterator = iter_impl<basic_json>

an iterator for a basic_json container

using const_iterator = iter_impl<const basic_json>

a const iterator for a basic_json container

using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>

a reverse iterator for a basic_json container

using const_reverse_iterator = json_reverse_iterator<typename basic_json::const_iterator>

a const reverse iterator for a basic_json container

JSON value data types

The data types to store a JSON value. These types are derived from the template arguments passed to class basic_json.

using default_object_comparator_t = std::less<StringType>

default object key comparator type The actual object key comparator type (object_comparator_t) may be different.

using object_t = ObjectType<StringType, basic_json, default_object_comparator_t, AllocatorType<std::pair<const StringType, basic_json>>>

a type for an object

using array_t = ArrayType<basic_json, AllocatorType<basic_json>>

a type for an array

using string_t = StringType

a type for a string

using boolean_t = BooleanType

a type for a boolean

using number_integer_t = NumberIntegerType

a type for a number (integer)

using number_unsigned_t = NumberUnsignedType

a type for a number (unsigned)

using number_float_t = NumberFloatType

a type for a number (floating-point)

using binary_t = nlohmann::byte_container_with_subtype<BinaryType>

a type for a packed binary type

using object_comparator_t = detail::actual_object_comparator_t<basic_json>

object key comparator type

modifiers

checks whether the container is empty.

returns the number of elements

returns the maximum possible number of elements

inline friend void swap (reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)

exchanges the values

inline reference operator+=(basic_json &&val)

add an object to an array

inline void push_back(const basic_json &val)

add an object to an array

inline reference operator+=(const basic_json &val)

add an object to an array

inline void push_back(const typename object_t::value_type &val)

add an object to an object

inline reference operator+=(const typename object_t::value_type &val)

add an object to an object

inline void push_back(initializer_list_t init)

add an object to an object

inline reference operator+=(initializer_list_t init)

add an object to an object

template<class ...Args>
inline reference emplace_back(Args&&... args)

add an object to an array

template<class ...Args>
inline std::pair<iterator, bool> emplace(Args&&... args)

add an object to an object if key does not exist

template<typename ...Args>
inline iterator insert_iterator(const_iterator pos, Args&&... args)

Helper for insertion of an iterator

Note

: This uses std::distance to support GCC 4.8, see https://github.com/nlohmann/json/pull/1257

inline iterator insert(const_iterator pos, const basic_json &val)

inserts element into array

inline iterator insert(const_iterator pos, basic_json &&val)

inserts element into array

inline iterator insert(const_iterator pos, size_type cnt, const basic_json &val)

inserts copies of element into array

inline iterator insert(const_iterator pos, const_iterator first, const_iterator last)

inserts range of elements into array

inline iterator insert(const_iterator pos, initializer_list_t ilist)

inserts elements from initializer list into array

inline void insert(const_iterator first, const_iterator last)

inserts range of elements into object

inline void update(const_reference j, bool merge_objects = false)

updates a JSON object from another object, overwriting existing keys

inline void update(const_iterator first, const_iterator last, bool merge_objects = false)

updates a JSON object from another object, overwriting existing keys

inline void swap (reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)

exchanges the values

inline void swap(array_t &other)

exchanges the values

inline void swap(object_t &other)

exchanges the values

inline void swap(string_t &other)

exchanges the values

inline void swap(binary_t &other)

exchanges the values

inline void swap(typename binary_t::container_type &other)

exchanges the values

lexicographical comparison operators

JSON_PRIVATE_UNLESS_TESTED __pad3__
JSON_PRIVATE_UNLESS_TESTED const_reference rhs
JSON_PRIVATE_UNLESS_TESTED const_reference bool inverse

value access

Direct access to the stored value of a JSON value.

template<typename ValueType, detail::enable_if_t<detail::is_default_constructible<ValueType>::value && detail::has_from_json<basic_json_t, ValueType>::value, int> = 0>
inline ValueType get_impl(detail::priority_tag<0>) const noexcept(noexcept(JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))

get a value (explicit)

Explicit type conversion between the JSON value and a compatible value which is CopyConstructible and DefaultConstructible. The value is converted by calling the json_serializer<ValueType> from_json() method.

The function is equivalent to executing

ValueType ret;
JSONSerializer<ValueType>::from_json(*this, ret);
return ret;

This overloads is chosen if:

  • ValueType is not basic_json,

  • json_serializer<ValueType> has a from_json() method of the form void from_json(const basic_json&, ValueType&), and

  • json_serializer<ValueType> does not have a from_json() method of the form ValueType from_json(const basic_json&)

@liveexample{The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers\, (2) A JSON array can be converted to a standard std::vector<short>\, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string\, json>.,get__ValueType_const}

Since

version 2.1.0

Template Parameters:

ValueType – the returned value type

Throws:

what – json_serializer<ValueType> from_json() method throws

Returns:

copy of the JSON value, converted to ValueType

template<typename ValueType, detail::enable_if_t<detail::has_non_default_from_json<basic_json_t, ValueType>::value, int> = 0>
inline ValueType get_impl(detail::priority_tag<1>) const noexcept(noexcept(JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))

get a value (explicit); special case

Explicit type conversion between the JSON value and a compatible value which is not CopyConstructible and not DefaultConstructible. The value is converted by calling the json_serializer<ValueType> from_json() method.

The function is equivalent to executing

return JSONSerializer<ValueType>::from_json(*this);

This overloads is chosen if:

  • ValueType is not basic_json and

  • json_serializer<ValueType> has a from_json() method of the form ValueType from_json(const basic_json&)

Since

version 2.1.0

Note

If json_serializer<ValueType> has both overloads of from_json(), this one is chosen.

Template Parameters:

ValueType – the returned value type

Throws:

what – json_serializer<ValueType> from_json() method throws

Returns:

copy of the JSON value, converted to ValueType

template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value, int> = 0>
inline BasicJsonType get_impl(detail::priority_tag<2>) const

get special-case overload

This overloads converts the current basic_json in a different basic_json type

@complexity Depending on the implementation of the called from_json() method.

Since

version 3.2.0

Template Parameters:

BasicJsonType – == basic_json

Returns:

a copy of *this, converted into BasicJsonType

template<typename BasicJsonType, detail::enable_if_t<std::is_same<BasicJsonType, basic_json_t>::value, int> = 0>
inline basic_json get_impl(detail::priority_tag<3>) const

get special-case overload

This overloads avoids a lot of template boilerplate, it can be seen as the identity method

@complexity Constant.

Since

version 2.1.0

Template Parameters:

BasicJsonType – == basic_json

Returns:

a copy of *this

template<typename PointerType, detail::enable_if_t< std::is_pointer< PointerType >::value, int > = 0> inline constexpr auto get_impl (detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())

get a pointer value (explicit)

get a pointer value (explicit) Explicit pointer access to the internally stored JSON value. No copies are made.

@complexity Constant.

@liveexample{The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.,get__PointerType}

See also

see get_ptr() for explicit pointer-member access

Since

version 1.0.0

Warning

The pointer becomes invalid if the underlying JSON object changes.

Template Parameters:

PointerType – pointer type; must be a pointer to array_t, object_t, string_t, boolean_t, number_integer_t, number_unsigned_t, or number_float_t.

Returns:

pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise

template<typename PointerType, typename std::enable_if<std::is_pointer<PointerType>::value, int>::type = 0>
inline auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))

get a pointer value (implicit)

template<typename PointerType, typename std::enable_if<std::is_pointer<PointerType>::value && std::is_const<typename std::remove_pointer<PointerType>::type>::value, int>::type = 0>
inline constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))

get a pointer value (implicit)

template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>> inline auto get () const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))

get a (pointer) value (explicit)

Performs explicit type conversion between the JSON value and a compatible value if required.

  • If the requested type is a pointer to the internally stored JSON value that pointer is returned. No copies are made.

  • If the requested type is the current basic_json, or a different basic_json convertible from the current basic_json.

  • Otherwise the value is converted by calling the json_serializer<ValueType> from_json() method.

Since

version 2.1.0

Template Parameters:
  • ValueTypeCV – the provided value type

  • ValueType – the returned value type

  • ValueType – if necessary

Throws:

what – json_serializer<ValueType> from_json() method throws if conversion is required

Returns:

copy of the JSON value, converted to

template<typename PointerType, typename std::enable_if< std::is_pointer< PointerType >::value, int >::type = 0> inline auto get () noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())

get a pointer value (explicit)

Explicit pointer access to the internally stored JSON value. No copies are made.

@complexity Constant.

@liveexample{The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.,get__PointerType}

See also

see get_ptr() for explicit pointer-member access

Since

version 1.0.0

Warning

The pointer becomes invalid if the underlying JSON object changes.

Template Parameters:

PointerType – pointer type; must be a pointer to array_t, object_t, string_t, boolean_t, number_integer_t, number_unsigned_t, or number_float_t.

Returns:

pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise

template<typename ValueType, detail::enable_if_t<!detail::is_basic_json<ValueType>::value && detail::has_from_json<basic_json_t, ValueType>::value, int> = 0>
inline ValueType &get_to(ValueType &v) const noexcept(noexcept(JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))

get a value (explicit)

template<typename ValueType, detail::enable_if_t<detail::is_basic_json<ValueType>::value, int> = 0>
inline ValueType &get_to(ValueType &v) const
template<typename T, std::size_t N, typename Array = T (&)[N], detail::enable_if_t<detail::has_from_json<basic_json_t, Array>::value, int> = 0>
inline Array get_to(T (&v)[N]) const noexcept(noexcept(JSONSerializer<Array>::from_json(std::declval<const basic_json_t&>(), v)))
template<typename ReferenceType, typename std::enable_if<std::is_reference<ReferenceType>::value, int>::type = 0>
inline ReferenceType get_ref()

get a reference value (implicit)

template<typename ReferenceType, typename std::enable_if<std::is_reference<ReferenceType>::value && std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int>::type = 0>
inline ReferenceType get_ref() const

get a reference value (implicit)

template<typename ValueType, typename std::enable_if<detail::conjunction<detail::negation<std::is_pointer<ValueType>>, detail::negation<std::is_same<ValueType, std::nullptr_t>>, detail::negation<std::is_same<ValueType, detail::json_ref<basic_json>>>, detail::negation<std::is_same<ValueType, typename string_t::value_type>>, detail::negation<detail::is_basic_json<ValueType>>, detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>, detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>>::value, int>::type = 0>
inline JSON_EXPLICIT operator ValueType() const

get a value (implicit)

Implicit type conversion between the JSON value and a compatible value. The call is realized by calling get() const.

@complexity Linear in the size of the JSON value.

@liveexample{The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers\, (2) A JSON array can be converted to a standard std::vector<short>\, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string\, json>.,operator__ValueType}

Since

version 1.0.0

Template Parameters:

ValueType – non-pointer type compatible to the JSON value, for instance int for JSON integer numbers, bool for JSON booleans, or std::vector types for JSON arrays. The character type of string_t as well as an initializer list of this type is excluded to avoid ambiguities as these types implicitly convert to std::string.

Throws:

type_error.302 – in case passed type ValueType is incompatible to the JSON value type (e.g., the JSON value is of type boolean, but a string is requested); see example below

Returns:

copy of the JSON value, converted to type ValueType

inline binary_t &get_binary()

get a binary value

inline const binary_t &get_binary() const

get a binary value

constructors and destructors

Constructors of class basic_json, copy/move constructor, copy assignment, static functions creating objects, and the destructor.

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (const typename binary_t::container_type &init)

explicitly create a binary array (without subtype)

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)

explicitly create a binary array (with subtype)

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (typename binary_t::container_type &&init)

explicitly create a binary array

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary (typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)

explicitly create a binary array (with subtype)

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array (initializer_list_t init={})

explicitly create an array from an initializer list

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object (initializer_list_t init={})

explicitly create an object from an initializer list

inline basic_json(const value_t v)

create an empty value with a given type

inline basic_json(std::nullptr_t = nullptr) noexcept

create a null object

template<typename CompatibleType, typename U = detail::uncvref_t<CompatibleType>, detail::enable_if_t< !detail::is_basic_json< U >::value &&detail::is_compatible_type< basic_json_t, U >::value, int > = 0> inline  basic_json (CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))

create a JSON value from compatible types

template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value && !std::is_same<basic_json, BasicJsonType>::value, int> = 0>
inline basic_json(const BasicJsonType &val)

create a JSON value from an existing one

inline basic_json(initializer_list_t init, bool type_deduction = true, value_t manual_type = value_t::array)

create a container (array or object) from an initializer list

inline basic_json(size_type cnt, const basic_json &val)

construct an array with count copies of given value

template<class InputIT, typename std::enable_if<std::is_same<InputIT, typename basic_json_t::iterator>::value || std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int>::type = 0>
inline basic_json(InputIT first, InputIT last)

construct a JSON container given an iterator range

template<typename JsonRef, detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>, std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0>
inline basic_json(const JsonRef &ref)
inline basic_json(const basic_json &other)

copy constructor

inline basic_json(basic_json &&other) noexcept

move constructor

inline basic_json &operator=(basic_json other) noexcept(std::is_nothrow_move_constructible<value_t>::value && std::is_nothrow_move_assignable<value_t>::value && std::is_nothrow_move_constructible<json_value>::value && std::is_nothrow_move_assignable<json_value>::value && std::is_nothrow_move_assignable<json_base_class_t>::value)

copy assignment

inline ~basic_json() noexcept

destructor

binary serialization/deserialization support

static inline std::vector<std::uint8_t> to_cbor(const basic_json &j)

create a CBOR serialization of a given JSON value

static inline void to_cbor(const basic_json &j, detail::output_adapter<std::uint8_t> o)

create a CBOR serialization of a given JSON value

static inline void to_cbor(const basic_json &j, detail::output_adapter<char> o)

create a CBOR serialization of a given JSON value

static inline std::vector<std::uint8_t> to_msgpack(const basic_json &j)

create a MessagePack serialization of a given JSON value

static inline void to_msgpack(const basic_json &j, detail::output_adapter<std::uint8_t> o)

create a MessagePack serialization of a given JSON value

static inline void to_msgpack(const basic_json &j, detail::output_adapter<char> o)

create a MessagePack serialization of a given JSON value

static inline std::vector<std::uint8_t> to_ubjson(const basic_json &j, const bool use_size = false, const bool use_type = false)

create a UBJSON serialization of a given JSON value

static inline void to_ubjson(const basic_json &j, detail::output_adapter<std::uint8_t> o, const bool use_size = false, const bool use_type = false)

create a UBJSON serialization of a given JSON value

static inline void to_ubjson(const basic_json &j, detail::output_adapter<char> o, const bool use_size = false, const bool use_type = false)

create a UBJSON serialization of a given JSON value

static inline std::vector<std::uint8_t> to_bjdata(const basic_json &j, const bool use_size = false, const bool use_type = false)

create a BJData serialization of a given JSON value

static inline void to_bjdata(const basic_json &j, detail::output_adapter<std::uint8_t> o, const bool use_size = false, const bool use_type = false)

create a BJData serialization of a given JSON value

static inline void to_bjdata(const basic_json &j, detail::output_adapter<char> o, const bool use_size = false, const bool use_type = false)

create a BJData serialization of a given JSON value

static inline std::vector<std::uint8_t> to_bson(const basic_json &j)

create a BSON serialization of a given JSON value

static inline void to_bson(const basic_json &j, detail::output_adapter<std::uint8_t> o)

create a BSON serialization of a given JSON value

static inline void to_bson(const basic_json &j, detail::output_adapter<char> o)

create a BSON serialization of a given JSON value

template<typename InputType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)

create a JSON value from an input in CBOR format

template<typename IteratorType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)

create a JSON value from an input in CBOR format

template<typename T> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
template<typename InputType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (InputType &&i, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in MessagePack format

template<typename IteratorType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in MessagePack format

template<typename T> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
template<typename InputType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (InputType &&i, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in UBJSON format

template<typename IteratorType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in UBJSON format

template<typename T> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)
template<typename InputType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata (InputType &&i, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in BJData format

template<typename IteratorType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in BJData format

template<typename InputType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (InputType &&i, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in BSON format

template<typename IteratorType> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)

create a JSON value from an input in BSON format

template<typename T> static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (const T *ptr, std::size_t len, const bool strict=true, const bool allow_exceptions=true)
static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson (detail::span_input_adapter &&i, const bool strict=true, const bool allow_exceptions=true)

JSON Patch functions

return flattened JSON value

unflatten a previously flattened JSON value

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff (const basic_json &source, const basic_json &target, const std::string &path="")

creates a diff as a JSON patch

inline basic_json patch(const basic_json &json_patch) const

applies a JSON patch to a copy of the current object

object inspection

Functions to inspect the type of a JSON value.

inline string_t dump(const int indent = -1, const char indent_char = ' ', const bool ensure_ascii = false, const error_handler_t error_handler = error_handler_t::strict) const

serialization

inline constexpr value_t type() const noexcept

return the type of the JSON value (explicit)

inline constexpr bool is_primitive() const noexcept

return whether type is primitive

inline constexpr bool is_structured() const noexcept

return whether type is structured

inline constexpr bool is_null() const noexcept

return whether value is null

inline constexpr bool is_boolean() const noexcept

return whether value is a boolean

inline constexpr bool is_number() const noexcept

return whether value is a number

inline constexpr bool is_number_integer() const noexcept

return whether value is an integer number

inline constexpr bool is_number_unsigned() const noexcept

return whether value is an unsigned integer number

inline constexpr bool is_number_float() const noexcept

return whether value is a floating-point number

inline constexpr bool is_object() const noexcept

return whether value is an object

inline constexpr bool is_array() const noexcept

return whether value is an array

inline constexpr bool is_string() const noexcept

return whether value is a string

inline constexpr bool is_binary() const noexcept

return whether value is a binary array

inline constexpr bool is_discarded() const noexcept

return whether value is discarded

inline constexpr operator value_t() const noexcept

return the type of the JSON value (implicit)

lookup

inline iterator find(const typename object_t::key_type &key)

find an element in a JSON object

inline const_iterator find(const typename object_t::key_type &key) const

find an element in a JSON object

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline iterator find(KeyType &&key)

find an element in a JSON object

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline const_iterator find(KeyType &&key) const

find an element in a JSON object

inline size_type count(const typename object_t::key_type &key) const

returns the number of occurrences of a key in a JSON object

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline size_type count(KeyType &&key) const

returns the number of occurrences of a key in a JSON object

inline bool contains(const typename object_t::key_type &key) const

check the existence of an element in a JSON object

template<class KeyType, detail::enable_if_t<detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int> = 0>
inline bool contains(KeyType &&key) const

check the existence of an element in a JSON object

inline bool contains(const json_pointer &ptr) const

check the existence of an element in a JSON object given a JSON pointer

JSON Pointer functions

inline reference operator[](const json_pointer &ptr)

access specified element via JSON Pointer

template<typename BasicJsonType, detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> inline  JSON_HEDLEY_DEPRECATED_FOR (3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference operator[](const
inline const_reference operator[](const json_pointer &ptr) const

access specified element via JSON Pointer

template<typename BasicJsonType, detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> inline  JSON_HEDLEY_DEPRECATED_FOR (3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) const _reference operator[](const

access specified element via JSON Pointer

template<typename BasicJsonType, detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value, int > = 0> inline  JSON_HEDLEY_DEPRECATED_FOR (3.11.0, basic_json::json_pointer or nlohmann::json_pointer< basic_json::string_t >) reference at(const
inline const_reference at(const json_pointer &ptr) const

access specified element via JSON Pointer

JSON Merge Patch functions

inline void merge_patch(const basic_json &apply_patch)

applies a JSON Merge Patch

Public Types

using value_t = detail::value_t
using json_pointer = ::nlohmann::json_pointer<StringType>

JSON Pointer, see nlohmann::json_pointer.

template<typename T, typename SFINAE>
using json_serializer = JSONSerializer<T, SFINAE>
using error_handler_t = detail::error_handler_t

how to treat decoding errors

using cbor_tag_handler_t = detail::cbor_tag_handler_t

how to treat CBOR tags

using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>

helper type for initializer lists of basic_json values

using input_format_t = detail::input_format_t
using json_sax_t = json_sax<basic_json>

SAX interface type, see nlohmann::json_sax.

using parse_event_t = detail::parse_event_t

parser event types

using parser_callback_t = detail::parser_callback_t<basic_json>

per-element parser callback type

Public Functions

inline JSON_HEDLEY_RETURNS_NON_NULL const char * type_name () const noexcept

return the type as string

inline data(const value_t v)
inline data(size_type cnt, const basic_json &val)
data() noexcept = default
data(data&&) noexcept = default
data(const data&) noexcept = delete
data &operator=(data&&) noexcept = delete
data &operator=(const data&) noexcept = delete
inline ~data() noexcept

Public Members

JSON_PRIVATE_UNLESS_TESTED __pad4__
json_value m_value = {}

the value of the current element

data m_data = {}

Public Static Functions

static inline allocator_type get_allocator()

returns the allocator associated with the container

static inline JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta ()

returns version information on the library

static inline JSON_PRIVATE_UNLESS_TESTED const_reference bool SAX bool sax_parse (InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
template<class IteratorType, class SAX>
static inline bool sax_parse(IteratorType first, IteratorType last, SAX *sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false)

generate SAX events

template<typename SAX>
static inline bool sax_parse(detail::span_input_adapter &&i, SAX *sax, input_format_t format = input_format_t::json, const bool strict = true, const bool ignore_comments = false)

generate SAX events

Deprecated:

This function is deprecated since 3.8.0 and will be removed in version 4.0.0 of the library. Please use sax_parse(ptr, ptr + len) instead.

Private Types

using basic_json_t = NLOHMANN_BASIC_JSON_TPL

workaround type for MSVC

using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>
using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t
template<typename BasicJsonType>
using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>
template<typename BasicJsonType>
using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>
template<typename Iterator>
using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>
template<typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>
template<typename CharType>
using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>
template<typename InputType>
using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>
template<typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>

Private Functions

template<typename InputAdapterType>
inline ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(InputAdapterType adapter, detail::parser_callback_t<basic_json> cb = nullptr, const bool allow_exceptions = true, const bool ignore_comments = false)
json_value() = default

default constructor (for null values)

inline json_value(boolean_t v) noexcept

constructor for booleans

inline json_value(number_integer_t v) noexcept

constructor for numbers (integer)

inline json_value(number_unsigned_t v) noexcept

constructor for numbers (unsigned)

inline json_value(number_float_t v) noexcept

constructor for numbers (floating-point)

inline json_value(value_t t)

constructor for empty values of a given type

inline json_value(const string_t &value)

constructor for strings

inline json_value(string_t &&value)

constructor for rvalue strings

inline json_value(const object_t &value)

constructor for objects

inline json_value(object_t &&value)

constructor for rvalue objects

inline json_value(const array_t &value)

constructor for arrays

inline json_value(array_t &&value)

constructor for rvalue arrays

inline json_value(const typename binary_t::container_type &value)

constructor for binary arrays

inline json_value(typename binary_t::container_type &&value)

constructor for rvalue binary arrays

inline json_value(const binary_t &value)

constructor for binary arrays (internal type)

inline json_value(binary_t &&value)

constructor for rvalue binary arrays (internal type)

inline void destroy(value_t t)
inline void assert_invariant(bool check_parents = true) const noexcept

checks the class invariants

This function asserts the class invariants. It needs to be called at the end of every constructor to make sure that created objects respect the invariant. Furthermore, it has to be called each time the type of a JSON value is changed, because the invariant expresses a relationship between m_type and m_value.

Furthermore, the parent relation is checked for arrays and objects: If check_parents true and the value is an array or object, then the container’s elements must have the current value as parent.

Parameters:

check_parents[in] whether the parent relation should be checked. The value is true by default and should only be set to false during destruction of objects when the invariant does not need to hold.

inline void set_parents()
inline iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
inline reference set_parent(reference j, std::size_t old_capacity = static_cast<std::size_t>(-1))
inline boolean_t get_impl(boolean_t*) const

get a boolean (explicit)

inline object_t *get_impl_ptr(object_t*) noexcept

get a pointer to the value (object)

inline constexpr const object_t *get_impl_ptr(const object_t*) const noexcept

get a pointer to the value (object)

inline array_t *get_impl_ptr(array_t*) noexcept

get a pointer to the value (array)

inline constexpr const array_t *get_impl_ptr(const array_t*) const noexcept

get a pointer to the value (array)

inline string_t *get_impl_ptr(string_t*) noexcept

get a pointer to the value (string)

inline constexpr const string_t *get_impl_ptr(const string_t*) const noexcept

get a pointer to the value (string)

inline boolean_t *get_impl_ptr(boolean_t*) noexcept

get a pointer to the value (boolean)

inline constexpr const boolean_t *get_impl_ptr(const boolean_t*) const noexcept

get a pointer to the value (boolean)

inline number_integer_t *get_impl_ptr(number_integer_t*) noexcept

get a pointer to the value (integer number)

inline constexpr const number_integer_t *get_impl_ptr(const number_integer_t*) const noexcept

get a pointer to the value (integer number)

inline number_unsigned_t *get_impl_ptr(number_unsigned_t*) noexcept

get a pointer to the value (unsigned number)

inline constexpr const number_unsigned_t *get_impl_ptr(const number_unsigned_t*) const noexcept

get a pointer to the value (unsigned number)

inline number_float_t *get_impl_ptr(number_float_t*) noexcept

get a pointer to the value (floating-point number)

inline constexpr const number_float_t *get_impl_ptr(const number_float_t*) const noexcept

get a pointer to the value (floating-point number)

inline binary_t *get_impl_ptr(binary_t*) noexcept

get a pointer to the value (binary)

inline constexpr const binary_t *get_impl_ptr(const binary_t*) const noexcept

get a pointer to the value (binary)

Private Members

JSON_PRIVATE_UNLESS_TESTED __pad0__
JSON_PRIVATE_UNLESS_TESTED __pad1__
JSON_PRIVATE_UNLESS_TESTED __pad2__
array_t *array

array (stored with pointer to save storage)

string_t *string

string (stored with pointer to save storage)

binary_t *binary

binary (stored with pointer to save storage)

boolean_t boolean

boolean

number_integer_t number_integer

number (integer)

number_unsigned_t number_unsigned

number (unsigned integer)

number_float_t number_float

number (floating-point)

Private Static Functions

template<typename T, typename... Args> static inline JSON_HEDLEY_RETURNS_NON_NULL T * create (Args &&... args)

helper for exception-safe object creation

template<typename ReferenceType, typename ThisType>
static inline ReferenceType get_ref_impl(ThisType &obj)

helper function to implement get_ref()

This function helps to implement get_ref() without code duplication for const and non-const overloads

Template Parameters:

ThisType – will be deduced as basic_json or const basic_json

Throws:

type_error.303 – if ReferenceType does not match underlying value type of the current JSON

Friends

friend struct detail::external_constructor
friend class ::nlohmann::json_pointer
friend class ::nlohmann::detail::parser
friend class ::nlohmann::detail::iter_impl
friend class ::nlohmann::detail::binary_writer
friend class ::nlohmann::detail::binary_reader
friend class ::nlohmann::detail::json_sax_dom_parser
friend class ::nlohmann::detail::json_sax_dom_callback_parser
friend class ::nlohmann::detail::exception
inline friend std::istream &operator<<(basic_json &j, std::istream &i)

deserialize from stream

Deprecated:

This stream operator is deprecated since 3.0.0 and will be removed in version 4.0.0 of the library. Please use operator>>(std::istream&, basic_json&) instead; that is, replace calls like j << i; with i >> j;.

inline friend std::istream &operator>>(std::istream &i, basic_json &j)

deserialize from stream

class BicycleVehicleModelDynamics : public rlenvscpp::dynamics::MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>>

The BicycleVehicleModelDynamics class. Implements the bicycle vehicle model dynamics. The implementation of the dynamics is taken from the paper: Deep Reinforcement Learning for Mobile Robot Path Planning by Hao Liu, Yi Shen, Shuangjiang Yu, Zijun Gao, Tong Wu The state of the model is described by the tuple (X, Y, Phi) where (X,Y) denotes the 2D position of the vehicle in the world coordinates and phi denotes the heading of the vehicle.

Public Types

typedef MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>> base_type
typedef base_type::state_type state_type
typedef base_type::input_type input_type
typedef base_type::matrix_descriptor_type matrix_descriptor_type
typedef matrix_descriptor_type::matrix_type matrix_type
typedef matrix_descriptor_type::vector_type vector_type

Public Functions

BicycleVehicleModelDynamics(const BicycleVehicleModelDynamicsConfig config, SysState<3> &init_state)

Constructor.

void integrate(const input_type &input)

integrate. Integrate the dynamics equations the model expects the following inputs the velocity of the vehicle v and the angle delta of the front wheel

state_type &evaluate(const input_type &input)

evaluate

Parameters:

input

Returns:

void initialize_matrices(const input_type &input)

initialize_matrices. Initialize the matrix description of the dynamics

void update_matrices(const input_type &input)

update_matrices. Update the matrix description of the dynamics

inline void load_from_json(const std::string &filename)

load_from_json Load the description of the chassis from the given json file

Private Members

BicycleVehicleModelDynamicsConfig config_

Configuration of the dynamics integrator.

struct BicycleVehicleModelDynamicsConfig

Public Members

real_t dt

The time step to use in secs.

real_t L

The distance between the front and real wheels in m.

template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
class binary_reader
#include <json.hpp>

deserialization of CBOR, MessagePack, and UBJSON values

Public Functions

inline explicit binary_reader(InputAdapterType &&adapter, const input_format_t format = input_format_t::json) noexcept

create a binary reader

Parameters:

adapter[in] input adapter to read from

binary_reader(const binary_reader&) = delete
binary_reader(binary_reader&&) = default
binary_reader &operator=(const binary_reader&) = delete
binary_reader &operator=(binary_reader&&) = default
~binary_reader() = default
inline bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict = true, const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
Parameters:
  • format[in] the binary format to parse

  • sax_[in] a SAX event processor

  • strict[in] whether to expect the input to be consumed completed

  • tag_handler[in] how to treat CBOR tags

Returns:

whether parsing was successful

Private Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t
using json_sax_t = SAX
using char_type = typename InputAdapterType::char_type
using char_int_type = typename char_traits<char_type>::int_type
using bjd_type = std::pair<char_int_type, string_t>

Private Functions

inline bool parse_bson_internal()

Reads in a BSON-object and passes it to the SAX-parser.

Returns:

whether a valid BSON-value was passed to the SAX parser

inline bool get_bson_cstr(string_t &result)

Parses a C-style string from the BSON input.

Parameters:

result[inout] A reference to the string variable where the read string is to be stored.

Returns:

true if the \x00-byte indicating the end of the string was encountered before the EOF; false` indicates an unexpected EOF.

template<typename NumberType>
inline bool get_bson_string(const NumberType len, string_t &result)

Parses a zero-terminated string of length len from the BSON input.

Parameters:
  • len[in] The length (including the zero-byte at the end) of the string to be read.

  • result[inout] A reference to the string variable where the read string is to be stored.

Template Parameters:

NumberType – The type of the length len

Pre:

len >= 1

Returns:

true if the string was successfully parsed

template<typename NumberType>
inline bool get_bson_binary(const NumberType len, binary_t &result)

Parses a byte array input of length len from the BSON input.

Parameters:
  • len[in] The length of the byte array to be read.

  • result[inout] A reference to the binary variable where the read array is to be stored.

Template Parameters:

NumberType – The type of the length len

Pre:

len >= 0

Returns:

true if the byte array was successfully parsed

inline bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)

Read a BSON document element of the given element_type.

Warning

Not all BSON element types are supported yet. An unsupported element_type will give rise to a parse_error.114: Unsupported BSON record type 0x…

Parameters:
  • element_type[in] The BSON element type, c.f. http://bsonspec.org/spec.html

  • element_type_parse_position[in] The position in the input stream, where the element_type was read.

Returns:

whether a valid BSON-object/array was passed to the SAX parser

inline bool parse_bson_element_list(const bool is_array)

Read a BSON element list (as specified in the BSON-spec)

The same binary layout is used for objects and arrays, hence it must be indicated with the argument is_array which one is expected (true –> array, false –> object).

Parameters:

is_array[in] Determines if the element list being read is to be treated as an object (is_array == false), or as an array (is_array == true).

Returns:

whether a valid BSON-object/array was passed to the SAX parser

inline bool parse_bson_array()

Reads an array from the BSON input and passes it to the SAX-parser.

Returns:

whether a valid BSON-array was passed to the SAX parser

inline bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
Parameters:
  • get_char[in] whether a new character should be retrieved from the input (true) or whether the last read character should be considered instead (false)

  • tag_handler[in] how CBOR tags should be treated

Returns:

whether a valid CBOR value was passed to the SAX parser

inline bool get_cbor_string(string_t &result)

reads a CBOR string

This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string. Additionally, CBOR’s strings with indefinite lengths are supported.

Parameters:

result[out] created string

Returns:

whether string creation completed

inline bool get_cbor_binary(binary_t &result)

reads a CBOR byte array

This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into the byte array. Additionally, CBOR’s byte arrays with indefinite lengths are supported.

Parameters:

result[out] created byte array

Returns:

whether byte array creation completed

inline bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
Parameters:
  • len[in] the length of the array or static_cast<std::size_t>(-1) for an array of indefinite size

  • tag_handler[in] how CBOR tags should be treated

Returns:

whether array creation completed

inline bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
Parameters:
  • len[in] the length of the object or static_cast<std::size_t>(-1) for an object of indefinite size

  • tag_handler[in] how CBOR tags should be treated

Returns:

whether object creation completed

inline bool parse_msgpack_internal()
Returns:

whether a valid MessagePack value was passed to the SAX parser

inline bool get_msgpack_string(string_t &result)

reads a MessagePack string

This function first reads starting bytes to determine the expected string length and then copies this number of bytes into a string.

Parameters:

result[out] created string

Returns:

whether string creation completed

inline bool get_msgpack_binary(binary_t &result)

reads a MessagePack byte array

This function first reads starting bytes to determine the expected byte array length and then copies this number of bytes into a byte array.

Parameters:

result[out] created byte array

Returns:

whether byte array creation completed

inline bool get_msgpack_array(const std::size_t len)
Parameters:

len[in] the length of the array

Returns:

whether array creation completed

inline bool get_msgpack_object(const std::size_t len)
Parameters:

len[in] the length of the object

Returns:

whether object creation completed

inline bool parse_ubjson_internal(const bool get_char = true)
Parameters:

get_char[in] whether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead

Returns:

whether a valid UBJSON value was passed to the SAX parser

inline bool get_ubjson_string(string_t &result, const bool get_char = true)

reads a UBJSON string

This function is either called after reading the ‘S’ byte explicitly indicating a string, or in case of an object key where the ‘S’ byte can be left out.

Parameters:
  • result[out] created string

  • get_char[in] whether a new character should be retrieved from the input (true, default) or whether the last read character should be considered instead

Returns:

whether string creation completed

inline bool get_ubjson_ndarray_size(std::vector<size_t> &dim)
Parameters:

dim[out] an integer vector storing the ND array dimensions

Returns:

whether reading ND array size vector is successful

inline bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix = 0)
Parameters:
  • result[out] determined size

  • is_ndarray[inout] for input, true means already inside an ndarray vector or ndarray dimension is not allowed; false means ndarray is allowed; for output, true means an ndarray is found; is_ndarray can only return true when its initial value is false

  • prefix[in] type marker if already read, otherwise set to 0

Returns:

whether size determination completed

inline bool get_ubjson_size_type(std::pair<std::size_t, char_int_type> &result, bool inside_ndarray = false)

determine the type and size for a container

In the optimized UBJSON format, a type and a size can be provided to allow for a more compact representation.

Parameters:
  • result[out] pair of the size and the type

  • inside_ndarray[in] whether the parser is parsing an ND array dimensional vector

Returns:

whether pair creation completed

inline bool get_ubjson_value(const char_int_type prefix)
Parameters:

prefix – the previously read or set type prefix

Returns:

whether value creation completed

inline bool get_ubjson_array()
Returns:

whether array creation completed

inline bool get_ubjson_object()
Returns:

whether object creation completed

inline bool get_ubjson_high_precision_number()
inline char_int_type get()

get next character from the input

This function provides the interface to the used input adapter. It does not throw in case the input reached EOF, but returns a -‘ve valued char_traits<char_type>::eof() in that case.

Returns:

character read from the input

inline char_int_type get_ignore_noop()
Returns:

character read from the input after ignoring all ‘N’ entries

template<typename NumberType, bool InputIsLittleEndian = false>
inline bool get_number(const input_format_t format, NumberType &result)
template<typename NumberType>
inline bool get_string(const input_format_t format, const NumberType len, string_t &result)

create a string by reading characters from the input

Note

We can not reserve len bytes for the result, because len may be too large. Usually, unexpect_eof() detects the end of the input before we run out of string memory.

Template Parameters:

NumberType – the type of the number

Parameters:
  • format[in] the current format (for diagnostics)

  • len[in] number of characters to read

  • result[out] string created by reading len bytes

Returns:

whether string creation completed

template<typename NumberType>
inline bool get_binary(const input_format_t format, const NumberType len, binary_t &result)

create a byte array by reading bytes from the input

Note

We can not reserve len bytes for the result, because len may be too large. Usually, unexpect_eof() detects the end of the input before we run out of memory.

Template Parameters:

NumberType – the type of the number

Parameters:
  • format[in] the current format (for diagnostics)

  • len[in] number of bytes to read

  • result[out] byte array created by reading len bytes

Returns:

whether byte array creation completed

inline bool unexpect_eof(const input_format_t format, const char *context) const
Parameters:
  • format[in] the current format (for diagnostics)

  • context[in] further context information (for diagnostics)

Returns:

whether the last read character is not EOF

inline std::string get_token_string() const
Returns:

a string representation of the last read byte

inline std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Parameters:
  • format[in] the current format

  • detail[in] a detailed error message

  • context[in] further context information

Returns:

a message string to use in the parse_error exceptions

Private Members

InputAdapterType ia

input adapter

char_int_type current = char_traits<char_type>::eof()

the current character

std::size_t chars_read = 0

the number of characters read

const bool is_little_endian = little_endianness()

whether we can assume little endianness

const input_format_t input_format = input_format_t::json

input format

json_sax_t *sax = nullptr

the SAX parser

JSON_PRIVATE_UNLESS_TESTED __pad0__
decltype(JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_) const bjd_types_map = JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_

Private Static Attributes

static constexpr JSON_INLINE_VARIABLE std::size_t npos   = static_cast<std::size_t>(-1)
template<typename BasicJsonType, typename CharType>
class binary_writer
#include <json.hpp>

serialization to CBOR and MessagePack values

Public Functions

inline explicit binary_writer(output_adapter_t<CharType> adapter)

create a binary writer

Parameters:

adapter[in] output adapter to write to

inline void write_bson(const BasicJsonType &j)
Parameters:

j[in] JSON value to serialize

Pre:

j.type() == value_t::object

inline void write_cbor(const BasicJsonType &j)
Parameters:

j[in] JSON value to serialize

inline void write_msgpack(const BasicJsonType &j)
Parameters:

j[in] JSON value to serialize

inline void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix = true, const bool use_bjdata = false)
Parameters:
  • j[in] JSON value to serialize

  • use_count[in] whether to use ‘#’ prefixes (optimized format)

  • use_type[in] whether to use ‘$’ prefixes (optimized format)

  • add_prefix[in] whether prefixes need to be used for this value

  • use_bjdata[in] whether write in BJData format, default is false

Public Static Functions

template<typename C = CharType, enable_if_t<std::is_signed<C>::value && std::is_signed<char>::value>* = nullptr>
static inline constexpr CharType to_char_type(std::uint8_t x) noexcept
template<typename C = CharType, enable_if_t<std::is_signed<C>::value && std::is_unsigned<char>::value>* = nullptr>
static inline CharType to_char_type(std::uint8_t x) noexcept
template<typename C = CharType, enable_if_t<std::is_unsigned<C>::value>* = nullptr>
static inline constexpr CharType to_char_type(std::uint8_t x) noexcept
template<typename InputCharType, typename C = CharType, enable_if_t<std::is_signed<C>::value && std::is_signed<char>::value && std::is_same<char, typename std::remove_cv<InputCharType>::type>::value>* = nullptr>
static inline constexpr CharType to_char_type(InputCharType x) noexcept

Private Types

using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t
using number_float_t = typename BasicJsonType::number_float_t

Private Functions

inline void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)

Writes the given element_type and name to the output adapter.

inline void write_bson_boolean(const string_t &name, const bool value)

Writes a BSON element with key name and boolean value value.

inline void write_bson_double(const string_t &name, const double value)

Writes a BSON element with key name and double value value.

inline void write_bson_string(const string_t &name, const string_t &value)

Writes a BSON element with key name and string value value.

inline void write_bson_null(const string_t &name)

Writes a BSON element with key name and null value.

inline void write_bson_integer(const string_t &name, const std::int64_t value)

Writes a BSON element with key name and integer value.

inline void write_bson_unsigned(const string_t &name, const BasicJsonType &j)

Writes a BSON element with key name and unsigned value.

inline void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)

Writes a BSON element with key name and object value.

inline void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)

Writes a BSON element with key name and array value.

inline void write_bson_binary(const string_t &name, const binary_t &value)

Writes a BSON element with key name and binary value value.

inline void write_bson_element(const string_t &name, const BasicJsonType &j)

Serializes the JSON value j to BSON and associates it with the key name.

Parameters:

name – The name to associate with the JSON entity j within the current BSON document

inline void write_bson_object(const typename BasicJsonType::object_t &value)
Parameters:

value[in] JSON value to serialize

Pre:

value.type() == value_t::object

template<typename NumberType, typename std::enable_if<std::is_floating_point<NumberType>::value, int>::type = 0>
inline void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
template<typename NumberType, typename std::enable_if<std::is_unsigned<NumberType>::value, int>::type = 0>
inline void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
template<typename NumberType, typename std::enable_if<std::is_signed<NumberType>::value && !std::is_floating_point<NumberType>::value, int>::type = 0>
inline void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
inline CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept

determine the type prefix of container values

inline bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type)
Returns:

false if the object is successfully converted to a bjdata ndarray, true if the type or size is invalid

template<typename NumberType>
inline void write_number(const NumberType n, const bool OutputIsLittleEndian = false)
inline void write_compact_float(const number_float_t n, detail::input_format_t format)

Private Members

const bool is_little_endian = little_endianness()

whether we can assume little endianness

output_adapter_t<CharType> oa = nullptr

the output

Private Static Functions

static inline std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Returns:

The size of a BSON document entry header, including the id marker and the entry name size (and its null-terminator).

static inline std::size_t calc_bson_string_size(const string_t &value)
Returns:

The size of the BSON-encoded string in value

static inline std::size_t calc_bson_integer_size(const std::int64_t value)
Returns:

The size of the BSON-encoded integer value

static inline constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Returns:

The size of the BSON-encoded unsigned integer in j

static inline std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Returns:

The size of the BSON-encoded array value

static inline std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Returns:

The size of the BSON-encoded binary array value

static inline std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)

Calculates the size necessary to serialize the JSON value j with its name.

Returns:

The calculated size for the BSON document entry for j with the given name.

static inline std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)

Calculates the size of the BSON serialization of the given JSON-object j.

Parameters:

value[in] JSON value to serialize

Pre:

value.type() == value_t::object

static inline constexpr CharType get_cbor_float_prefix(float)
static inline constexpr CharType get_cbor_float_prefix(double)
static inline constexpr CharType get_msgpack_float_prefix(float)
static inline constexpr CharType get_msgpack_float_prefix(double)
static inline constexpr CharType get_ubjson_float_prefix(float)
static inline constexpr CharType get_ubjson_float_prefix(double)
class BlackJack : public rlenvscpp::envs::gymnasium::ToyTextEnvBase<TimeStep<uint_t>, 48, 2>
#include <black_jack_env.h>

The BlackJack class. Wrapper to the Blackjack OpenAI-Gym environment.

Public Types

typedef ToyTextEnvBase<TimeStep<uint_t>, 48, 2>::base_type base_type

The base type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the action to be undertaken in the environment.

Public Functions

BlackJack(const RESTApiServerWrapper &api_server)

BlackJack. Constructor.

BlackJack(const RESTApiServerWrapper &api_server, const uint_t cidx)

Constructor.

BlackJack(const BlackJack &other)
~BlackJack() = default

~BlackJack. Destructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type step(const action_type &action) final override

step

Parameters:

action

Returns:

BlackJack make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline bool is_natural() const noexcept
inline bool is_sab() const noexcept

Public Static Attributes

static const std::string name = "BlackJack"

name

static const std::string URI = "/gymnasium/black-jack-env"

The URI for accessing the environment.

Protected Functions

virtual dynamics_t build_dynamics_from_response_(const nlohmann::json&) const final override

build the dynamics from response

virtual time_step_type create_time_step_from_response_(const nlohmann::json&) const final override

Handle the reset response from the environment server.

Private Functions

inline void make_natural() noexcept
inline void make_sab() noexcept

Private Members

bool is_natural_ = {false}

Flag indicating if the environment has been initialized as natural.

bool is_sab_ = {false}
struct board
#include <grid_world_env.h>

Represents the board

Public Functions

board_state_type init_board(uint_t board_s, GridWorldInitType init_type)

initialize the board

board_state_type step(GridWorldActionType action)

Execute the action on the board.

void move_piece(board_component_type piece, board_position pos)

move_piece Move the pice to the given position

Parameters:
  • piece

  • pos

board_state_type get_state() const

get_state. Returns the state of the board

Returns:

real_t get_reward() const

Get the reward the board currently returns depending on the position of the player.

void close()

close

void build_static_mode()

build_static_mode

void build_random_mode()

build_random_mode

void build_player_mode(uint_t seed)

build_player_mode

void check_and_move(uint_t row, uint_t col)

check if the given move is valid and change the position of the player if the move either causes the game to be lost (PIT) or is a valid move i.e. not stepping into the WALL or out of the board

board_move_type validate_move(board_component_type piece, board_position pos) const

validate_move_

Parameters:
  • piece

  • row

  • col

Public Members

uint_t board_size
uint_t seed = 42
std::map<board_component_type, board_piece> components
std::map<std::string, board_mask> masks
struct board_piece
#include <grid_world_env.h>

The BoardPiece struct.

Public Functions

inline board_piece(std::string name_, std::string code_, board_position pos_)

BoardPiece.

Parameters:
  • name_

  • code_

  • pos_

board_piece() = default

Default constructor.

Public Members

std::string name
std::string code

n ASCII character to display on the board

board_position pos

pos 2-tuple e.g. (1,4)

struct boundaries

Public Members

diyfp w
diyfp minus
diyfp plus
template<real_t S, real_t E>
struct BoundedContinuousScalarSpace
#include <space_type.h>

A space that represents a range of discrete.

Public Types

typedef real_t space_item_type

item_t

Public Static Attributes

static constexpr uint_t size = 1

The overall size of the space meaning how many elements can potentially the space have.

static constexpr RealRange<S, E> limits = RealRange<S, E>()

The boundaries the scalar value can assume.

template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
#include <json.hpp>

an internal type for a backed binary type

Public Types

using container_type = BinaryType
using subtype_type = std::uint64_t

Public Functions

inline byte_container_with_subtype() noexcept(noexcept(container_type()))

inline byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))

inline byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))

inline byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))

inline byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))

inline bool operator==(const byte_container_with_subtype &rhs) const
inline bool operator!=(const byte_container_with_subtype &rhs) const
inline void set_subtype(subtype_type subtype_) noexcept

sets the binary subtype

inline constexpr subtype_type subtype() const noexcept

return the binary subtype

inline constexpr bool has_subtype() const noexcept

return whether the value has a subtype

inline void clear_subtype() noexcept

clears the binary subtype

Private Members

subtype_type m_subtype = 0
bool m_has_subtype = false
struct cached_power

Public Members

std::uint64_t f
int e
int k
class CartPole : public rlenvscpp::envs::gymnasium::GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateDiscreteActionEnv<4, 2, 0, real_t>>
#include <cart_pole_env.h>

The CartPole class Interface for CartPole environment.

Public Types

typedef GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateDiscreteActionEnv<4, 2, 0, real_t>>::base_type base_type

Base class type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

Public Functions

CartPole(const RESTApiServerWrapper &api_server)

CartPole. Constructor.

CartPole(const RESTApiServerWrapper &api_server, const uint_t cidx)

CartPole. Constructor.

CartPole(const CartPole &other)

copy ctor

~CartPole() = default

~CartPole. Destructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any>&) final override

make. Build the environment

virtual time_step_type step(const action_type &action) final override

step. Step in the environment following the given action

CartPole make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

Public Static Attributes

static const std::string name = "CartPole"

name

static const std::string URI = "/gymnasium/cart-pole-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

Handle the reset response from the environment server.

template<typename T>
struct char_traits : public std::char_traits<T>
template<>
struct char_traits<signed char> : public std::char_traits<char>

Public Types

using char_type = signed char
using int_type = uint64_t

Public Static Functions

static inline int_type to_int_type(char_type c) noexcept
static inline char_type to_char_type(int_type i) noexcept
static inline constexpr int_type eof() noexcept
template<>
struct char_traits<unsigned char> : public std::char_traits<char>

Public Types

using char_type = unsigned char
using int_type = uint64_t

Public Static Functions

static inline int_type to_int_type(char_type c) noexcept
static inline char_type to_char_type(int_type i) noexcept
static inline constexpr int_type eof() noexcept
class Circle
#include <circle.h>

The Circle class. Models a common circle.

Public Functions

inline explicit Circle(real_t r)

Construct a circle centerd at the origin.

inline Circle(real_t r, const GeomPoint<2> &center)

Construct a circle given its radius and center.

inline real_t radius() const noexcept

Returns the radius of the circle.

inline GeomPoint<2> center() const noexcept

Returns the center of the circle.

inline real_t area() const

Returns the area.

inline bool is_inside(const GeomPoint<2> &point, real_t tol = rlenvscpp::consts::TOLERANCE) const

Returns true if the given point lies inside the circle.

inline bool is_inside(const real_t x, const real_t y, real_t tol = rlenvscpp::consts::TOLERANCE) const

Returns true if the given spatial point (x, y) lies within the circle.

Private Members

real_t r_

The radius of the circle.

GeomPoint<2> center_

The center of the circle.

class CliffWorld : public rlenvscpp::envs::gymnasium::ToyTextEnvBase<TimeStep<uint_t>, 37, 4>
#include <cliff_world_env.h>

The CliffWorld class.

Public Types

typedef std::vector<std::tuple<real_t, uint_t, real_t, bool>> dynamics_type

dynamics_t

typedef ToyTextEnvBase<TimeStep<uint_t>, 37, 4>::base_type base_type

The base type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the action to be undertaken in the environment.

Public Functions

CliffWorld(const RESTApiServerWrapper &api_server)

CliffWorld.

CliffWorld(const RESTApiServerWrapper &api_server, const uint_t cidx)

Constructor.

CliffWorld(const CliffWorld &other)

copy constructor

~CliffWorld() = default

~CliffWorld. Destructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type step(const action_type &action) final override

step

Parameters:

action

Returns:

CliffWorld make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

Public Static Attributes

static const std::string name = "CliffWalking"

name

static const std::string URI = "/gymnasium/cliff-walking-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

build the dynamics from response

Handle the reset response from the environment server

Protected Attributes

uint_t max_episode_steps_

Maximum episodes per step.

template<class...>
struct conjunction : public std::true_type
template<class B>
struct conjunction<B> : public B
template<class B, class ...Bn>
struct conjunction<B, Bn...> : public std::conditional::type
class Connect2 : public rlenvscpp::envs::EnvBase<TimeStep<std::vector<uint_t>>, DiscreteVectorStateDiscreteActionEnv<53, 0, 4, uint_t>>
#include <connect2_env.h>

Implementation of Connect2 environment from https://github.com/JoshVarty/AlphaZeroSimple Initially the environment has all its positions set to zero. When a player makes a move then the position corresponding to this move.

Public Types

typedef EnvBase<TimeStep<std::vector<uint_t>>, DiscreteVectorStateDiscreteActionEnv<53, 0, 4, uint_t>> base_type

The base type.

typedef base_type::time_step_type time_step_type

The type of the time step.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The state type.

Public Functions

Connect2()

Constructor.

explicit Connect2(uint_t cidx)

Constructor.

Connect2(const Connect2 &other)
virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type step(const action_type &action) final override

step. Move in the environment with the given action This function always moves player_1

Parameters:

action

Returns:

inline virtual void close() final override

close

virtual time_step_type reset(uint_t, const std::unordered_map<std::string, std::any>&) final override

Reset the environment.

Connect2 make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline uint_t n_states() const noexcept

n_states. Returns the number of states

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

time_step_type move(const uint_t pid, const action_type &action)

Make a move for the player with the given id.

bool is_win(uint_t player) const noexcept

Returns true if the player wins.

Returns true if there are still legal moves to do.

std::vector<uint_t> get_valid_moves() const

Get the valid moves.

Public Static Attributes

static const std::string name = "Connect2"

name

Private Members

real_t discount_

The discount factor.

const uint_t player_id_1_ = {1}

The id of player 1.

const uint_t player_id_2_ = {2}

The id of player 2.

const uint_t win_val_ = {2}

The wining value for a player.

std::vector<uint_t> board_

The representation of the board.

bool is_finished_ = {false}

Flag indicating if the game is finished.

template<typename ContainerType, typename Enable = void>
struct container_input_adapter_factory
template<typename ContainerType>
struct container_input_adapter_factory<ContainerType, void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>

Public Types

using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())))

Public Static Functions

static inline adapter_type create(const ContainerType &container)
template<uint_t Size>
struct ContinuousScalareSpace

Public Types

typedef real_t space_item_type

item_t

Public Static Attributes

static constexpr uint_t size = Size

The overall size of the space meaning how many elements can potentially the space have.

template<uint_t Size, typename T = real_t>
struct ContinuousVectorSpace

Public Types

typedef std::vector<T> space_item_type

item_t

Public Static Attributes

static constexpr uint_t size = Size

The overall size of the space meaning how many elements can potentially the space have.

template<uint_t StateSpaceSize, uint_t action_end, typename real_range, uint_t action_start = 0, typename StateSpaceItemType = real_t>
struct ContinuousVectorStateContinuousScalarBoundedActionEnv

Public Types

typedef ContinuousVectorSpace<StateSpaceSize, StateSpaceItemType> state_space

The type of the state space.

typedef state_space::space_item_type state_type

the State type

typedef ScalarDiscreteSpace<action_start, action_end> action_space

item_t

typedef real_range::value_type action_type

the Action type is real valued

Public Static Attributes

static constexpr uint_t STATE_SPACE_SIZE = state_space::size

state space size

static constexpr real_range action_limits = real_range()

the action limits

static constexpr uint_t ACTION_SPACE_SIZE = action_space::size

action space size

template<uint_t StateSpaceSize, uint_t action_end, uint_t action_start = 0, typename StateSpaceItemType = real_t>
struct ContinuousVectorStateDiscreteActionEnv

Public Types

typedef ContinuousVectorSpace<StateSpaceSize, StateSpaceItemType> state_space
typedef state_space::space_item_type state_type

the State type

typedef ScalarDiscreteSpace<action_start, action_end> action_space

item_t

typedef action_space::space_item_type action_type

the Action type

Public Static Functions

static inline action_type sample_action()

sample

Returns:

Public Static Attributes

static constexpr uint_t STATE_SPACE_SIZE = state_space::size

state space size

static constexpr uint_t ACTION_SPACE_SIZE = action_space::size

action space size

class CSVFileReader : public rlenvscpp::utils::io::FileReaderBase
#include <csv_file_reader.h>

The CSVFileReader class.

Public Functions

CSVFileReader(const std::string &file_path, const std::string delimeter = CSVFileReader::default_delimeter())

Constructor.

~CSVFileReader()

Destructor. Close the file if it is empty.

std::vector<std::string> read_line()

Read a line from the file. It attempts to open the file if the file is not already open.

std::vector<uint_t> read_line_as_uint()

read_line_as_uint. Read the line as uint

Public Static Functions

static inline std::string default_delimeter()

The default column delimiter.

Private Members

const std::string delimeter_

The delimiter.

uint_t current_row_idx_

The current row index.

class CSVWriter : public rlenvscpp::utils::io::FileWriterBase
#include <csv_file_writer.h>

The CSVWriter class. Handles writing into CSV file format.

Public Functions

CSVWriter(const std::string &filename, char delim = CSVWriter::default_delimiter())

Constructor.

void write_column_names(const std::vector<std::string> &col_names, bool write_header = true)

Write the column names.

void write_column_names(const std::vector<std::string_view> &col_names, bool write_header = true)

Write the column names.

void write_column_names(const std::initializer_list<std::string_view> &col_names, bool write_header = true)

Write the column names.

template<typename T>
void write_row(const std::vector<T> &vals)

Write a row of the file.

template<typename T>
void write_row(const DynVec<T> &vals)

Write the given Vec as a row.

template<typename T>
void write_column_vector(const std::vector<T> &vals)

Write the given vector as a column.

template<typename ...T>
void write_row(const std::tuple<T...> &row)

Write the given tuple as a row.

inline void set_delimiter(char delim) noexcept

Set the delimiter.

inline char get_delimiter() const noexcept

Returns the column delimiter.

Public Static Functions

static inline char default_delimiter()

The default column delimiter.

Private Members

char delim_

The delimiter used to separate the values.

template<class Default, class AlwaysVoid, template<class...> class Op, class ...Args>
struct detector

Public Types

using value_t = std::false_type
using type = Default
template<class Default, template<class...> class Op, class ...Args>
struct detector<Default, void_t<Op<Args...>>, Op, Args...>

Public Types

using value_t = std::true_type
using type = Op<Args...>
class DiffDriveDynamics : public rlenvscpp::dynamics::MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>>

DiffDriveDynamics class. Describes the motion dynamics of a differential drive system. It implements the following equations.

Public Types

enum class DynamicVersion

The DynamicVersion enum. Helper enum to disambiguate the two supplied configurations.

Values:

enumerator V1
enumerator V2
enumerator V3
typedef MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>>::state_type state_type

The type of the state handled by this dynamics object.

typedef MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>>::input_type input_type

input_t The type of the input for solving the dynamics

typedef MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>>::matrix_type matrix_type

matrix_t Matrix type that describes the dynamics

typedef MotionModelDynamicsBase<SysState<3>, DynamicsMatrixDescriptor, std::map<std::string, std::any>>::vector_type vector_type

vector_t

Public Functions

explicit DiffDriveDynamics(DynamicVersion type = DynamicVersion::V1, bool update_description_matrices_on_evaluate = true)

Constructor.

explicit DiffDriveDynamics(state_type &&state)

Constructor.

virtual state_type &evaluate(const input_type &input) override

Evaluate the new state using the given input it also updates the various matrices if needed.

void integrate(const input_type &input)

Integrate the new state. It also uses error terms.

inline real_t get_x_position() const

Read the x-coordinate.

inline void set_x_position(real_t x)

Set the x-coordinate.

inline real_t get_y_position() const

Read the y-coordinate.

inline void set_y_position(real_t y)

Set the y-coordinate.

inline real_t get_orientation() const

Read the y-coordinate.

inline void set_orientation(real_t theta)

Set the orientation.

inline real_t get_velocity() const

get_velocity Returns the velocity used for integration

inline real_t get_angular_velocity() const

get_velocity Returns the angular velocity used for integration

void update_matrices(const input_type &input)

updates the matrices used to describe this motion model

void initialize_matrices(const input_type &input)

Initialize the matrices describing the the dynamics.

Public Static Functions

static SysState<3> integrate_state_v1(const SysState<3> &state, real_t tol, real_t dt, real_t v, real_t w, const std::array<real_t, 2> &errors)

integrate_state_v1

static SysState<3> integrate_state_v2(const SysState<3> &state, real_t dt, real_t v, real_t w, const std::array<real_t, 2> &errors)

integrate_state_v2

static SysState<3> integrate_state_v3(const SysState<3> &state, real_t r, real_t l, real_t dt, real_t w1, real_t w2, const std::array<real_t, 2> &errors)

integrate_state_v3

static SysState<3> integrate(const SysState<3> &state, const input_type &input, const DynamicVersion version)

integrate Factory method to apply the different integration methods

Private Members

real_t v_

v_ The velocity used for integration. Updated every time the application calls integrate

real_t w_

w_ The angular velocity used for integration

DynamicVersion type_
template<uint_t SpaceSize, typename T = uint_t>
struct DiscreteVectorSpace

Public Types

typedef std::vector<T> space_item_type

item_t

Public Static Attributes

static constexpr uint_t size = SpaceSize

size. The number of members in the space

template<uint_t StateSpaceSize, uint_t AS, uint_t AE, typename StateSpaceItemType = uint_t>
struct DiscreteVectorStateDiscreteActionEnv

Subclassed by rlenvscpp::envs::EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > >

Public Types

typedef DiscreteVectorSpace<StateSpaceSize, StateSpaceItemType> state_space

the state space type

typedef state_space::space_item_type state_type

the State type

typedef ScalarDiscreteSpace<AS, AE> action_space

the action space type

typedef action_space::space_item_type action_type

the Action type

Public Static Attributes

static constexpr uint_t STATE_SPACE_SIZE = StateSpaceSize

state space size

static constexpr uint_t ACTION_SPACE_SIZE = action_space::size

state space size

struct diyfp

Public Functions

inline constexpr diyfp(std::uint64_t f_, int e_) noexcept

Public Members

std::uint64_t f = 0
int e = 0

Public Static Functions

static inline diyfp sub(const diyfp &x, const diyfp &y) noexcept

returns x - y

Pre:

x.e == y.e and x.f >= y.f

static inline diyfp mul(const diyfp &x, const diyfp &y) noexcept

returns x * y

Note

The result is rounded. (Only the upper q bits are returned.)

static inline diyfp normalize(diyfp x) noexcept

normalize x such that the significand is >= 2^(q-1)

Pre:

x.f != 0

static inline diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept

normalize x such that the result has the exponent E

Pre:

e >= x.e and the upper e - x.e bits of x.f must be zero.

Public Static Attributes

static constexpr int kPrecision = 64
class DynamicsMatrixDescriptor

The DynamicsMatrixDescriptor class. Helper class to model the matrix representon of dynamical systems.

Public Types

typedef DynMat<real_t> matrix_type
typedef DynVec<real_t> vector_type
typedef std::map<std::string, matrix_type>::iterator matrix_iterator
typedef std::map<std::string, matrix_type>::const_iterator const_matrix_iterator
typedef std::map<std::string, vector_type>::iterator vector_iterator
typedef std::map<std::string, vector_type>::const_iterator const_vector_iterator

Public Functions

DynamicsMatrixDescriptor()

Constructor.

inline ~DynamicsMatrixDescriptor()

Destructor.

matrix_iterator find_matrix(const std::string &name)

find the matrix with the given name

const_matrix_iterator find_matrix(const std::string &name) const

find the matrix with the given name

vector_iterator find_vector(const std::string &name)

find the matrix with the given name

const_vector_iterator find_vector(const std::string &name) const

find the matrix with the given name

matrix_type &get_matrix(const std::string &name)
const matrix_type &get_matrix(const std::string &name) const
inline void set_matrix(const std::string &name, const matrix_type &mat)
bool has_matrix(const std::string &name) const
vector_type &get_vector(const std::string &name)
const vector_type &get_vector(const std::string &name) const
inline void set_vector(const std::string &name, const vector_type &vec)
inline matrix_iterator matrix_begin()

iterators

inline matrix_iterator matrix_end()
inline const_matrix_iterator matrix_begin() const
inline const_matrix_iterator matrix_end() const
inline vector_iterator vector_begin()

iterators

inline vector_iterator vector_end()
inline const_vector_iterator vector_begin() const
inline const_vector_iterator vector_end() const

Protected Attributes

std::map<std::string, matrix_type> matrices_
std::map<std::string, vector_type> vectors_
template<typename TimeStepType, typename SpaceType>
class EnvBase : public SpaceType, public rlenvscpp::envs::synchronized_env_mixin
#include <env_base.h>

\ brief Base class for environments.

Subclassed by rlenvscpp::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t > >, rlenvscpp::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 3, 2, 0, real_t > >, rlenvscpp::envs::gymnasium::GymnasiumEnvBase< VectorTimeStepType, SpaceType >, rlenvscpp::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 6, 2, 0, real_t > >, rlenvscpp::envs::gymnasium::GymnasiumEnvBase< TimeStepType, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, rlenvscpp::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >, rlenvscpp::envs::gymnasium::GymnasiumEnvBase< TimeStepType, SpaceType >

Public Types

typedef TimeStepType time_step_type

The time step type we return every time a step in the environment is performed.

typedef SpaceType::state_space state_space_type

The type describing the state space for the environment.

typedef SpaceType::state_type state_type

The type of the state.

typedef SpaceType::action_space action_space_type

The type of the action space for the environment.

typedef SpaceType::action_type action_type

The type of the action to be undertaken in the environment.

Public Functions

virtual ~EnvBase() = default

dctor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) = 0

make. Builds the environment.

virtual void close() = 0

close the environment

virtual time_step_type reset(uint_t seed, const std::unordered_map<std::string, std::any> &options) = 0

Reset the environment.

virtual time_step_type step(const action_type &action) = 0

step in the environment by performing the given action

Parameters:

action – The action to execute in the environment

Returns:

The time step

inline time_step_type reset()

Reset the environment always using the same seed.

inline bool is_created() const noexcept

is_created Returns true is make has been called successfully

inline std::string version() const noexcept

version

inline std::string env_name() const noexcept

name of the environment

inline uint_t cidx() const noexcept

The number of agents acting in the environment.

Public Static Attributes

static const uint_t DEFAULT_ENV_SEED = 42

Protected Functions

explicit EnvBase(const uint_t cidx = 0, const std::string &name = rlenvscpp::consts::INVALID_STR)

Constructor.

EnvBase(const EnvBase&)

Copy constructor.

inline void set_version_(const std::string &version) noexcept

Helper function to set the version. To be called only when the make is called.

inline void invalidate_is_created_flag_() noexcept
inline void make_created_() noexcept

mark the environment as created

inline time_step_type &get_current_time_step_() noexcept
inline const time_step_type &get_current_time_step_() const noexcept

Private Members

bool is_created_

Flag indicating if the environment has been created.

uint_t cidx_

The copy idx

std::string version_

Version of the environment.

const std::string name_

Name of the environment.

time_step_type current_state_

current_state

class exception : public std::exception
#include <json.hpp>

general exception of the basic_json class

Subclassed by detail::invalid_iterator, detail::other_error, detail::out_of_range, detail::parse_error, detail::type_error

Public Functions

inline const char *what() const noexcept override

returns the explanatory string

Public Members

const int id

the id of the exception

Protected Functions

inline exception(int id_, const char *what_arg)

Protected Static Functions

static inline std::string name(const std::string &ename, int id_)
static inline std::string diagnostics(std::nullptr_t)
template<typename BasicJsonType>
static inline std::string diagnostics(const BasicJsonType *leaf_element)

Private Members

std::runtime_error m

an exception object as storage for error messages

template<typename Seq, size_t SeqSize, size_t Rem>
struct Extend
template<typename T, T... Ints, size_t SeqSize>
struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>

Public Types

using type = integer_sequence<T, Ints..., (Ints + SeqSize)...>
template<typename T, T... Ints, size_t SeqSize>
struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>

Public Types

type = integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize >
template<value_t>
struct external_constructor
template<>
struct external_constructor<value_t::array>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
template<typename BasicJsonType, typename CompatibleArrayType, enable_if_t<!std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value, int> = 0>
static inline void construct(BasicJsonType &j, const CompatibleArrayType &arr)
template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, const std::vector<bool> &arr)
template<typename BasicJsonType, typename T, enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
static inline void construct(BasicJsonType &j, const std::valarray<T> &arr)
template<>
struct external_constructor<value_t::binary>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
template<>
struct external_constructor<value_t::boolean>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
template<>
struct external_constructor<value_t::number_float>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
template<>
struct external_constructor<value_t::number_integer>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
template<>
struct external_constructor<value_t::number_unsigned>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
template<>
struct external_constructor<value_t::object>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
template<typename BasicJsonType, typename CompatibleObjectType, enable_if_t<!std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int> = 0>
static inline void construct(BasicJsonType &j, const CompatibleObjectType &obj)
template<>
struct external_constructor<value_t::string>

Public Static Functions

template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
template<typename BasicJsonType>
static inline void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
template<typename BasicJsonType, typename CompatibleStringType, enable_if_t<!std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value, int> = 0>
static inline void construct(BasicJsonType &j, const CompatibleStringType &str)
class file_input_adapter
#include <json.hpp>

Input adapter for stdio file access. This adapter read only 1 byte and do not use any buffer. This adapter is a very low level adapter.

Public Types

using char_type = char

Public Functions

inline explicit file_input_adapter(std::FILE *f) noexcept
file_input_adapter(const file_input_adapter&) = delete
file_input_adapter(file_input_adapter&&) noexcept = default
file_input_adapter &operator=(const file_input_adapter&) = delete
file_input_adapter &operator=(file_input_adapter&&) = delete
~file_input_adapter() = default
inline std::char_traits<char>::int_type get_character() noexcept

Private Members

std::FILE *m_file

the file pointer to read from

struct FileFormats
#include <file_formats.h>

Small struct that holds an enumeration for varioufile formats

Public Types

enum class Type

File formats types

Values:

enumerator CSV
enumerator JSON
enumerator INVALID_TYPE

Public Static Functions

static std::string type_to_string(Type t)

Return an std::string representation of the given file format type

template<typename HandlerType>
class FileHandlerBase : private boost::noncopyable

Todo:

write docs

Public Types

typedef HandlerType handler_type

Public Functions

virtual ~FileHandlerBase()

Constructor.

inline FileFormats::Type get_type() const noexcept

Returns the type of the file.

inline handler_type &get_file_stream() noexcept

Returns the underlying file stream.

inline const handler_type &get_file_stream() const noexcept

Returns the underlying file stream.

inline std::string get_filename() const noexcept

Returns the filename that is used to write.

inline bool is_open() const noexcept

Return true if and only if the file is open.

virtual void close()

Close the file. Return true if and only if the file was closed successfully false otherwise.

virtual void open() = 0

Open the file.

Protected Functions

FileHandlerBase(const std::string &file_name, FileFormats::Type t)

protected Constructor so that explicit instantiation of the class fails

Protected Attributes

std::string file_name_

The name of the file to write.

const FileFormats::Type t_

The format of the file.

handler_type f_

The low level file handler.

class FileReaderBase : public rlenvscpp::utils::io::FileHandlerBase<std::ifstream>
#include <file_reader_base.h>

Todo:

write docs

Subclassed by rlenvscpp::utils::io::CSVFileReader, rlenvscpp::utils::io::JSONFileReader

Public Functions

virtual ~FileReaderBase() = default
virtual void open() override

Attempts to open the file for reading.

inline bool eof() const

Returns true if the underlying stream handler has reached the EOF.

Protected Functions

FileReaderBase(const std::string &file_name, FileFormats::Type t)

Constructor.

class FileWriterBase : public rlenvscpp::utils::io::FileHandlerBase<std::ofstream>
#include <file_writer_base.h>

The FileWriterBase class.

Subclassed by rlenvscpp::utils::io::CSVWriter

Public Functions

FileWriterBase() = default

Default ctor.

FileWriterBase(const std::string &file_name, FileFormats::Type t)

Constructor. Construct by passing the name of the file to write into.

virtual ~FileWriterBase()

Destructor.

virtual void open() override

Open the file for writing.

inline char get_comment_mark() const

Return the mark that signifies the beginning of a comment line.

inline void set_comment_mark(char mark)

Set the comment mark.

virtual void write_header()

Write the header of the file. By default some information such as date and time the file was created is written.

Public Static Functions

static inline char default_comment_mark()

The default comment mark.

Protected Attributes

char comment_mark_

The mark that signifies the beginning of a comment line. The default is #.

struct from_json_fn

Public Functions

template<typename BasicJsonType, typename T>
inline auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward<T>(val)))) -> decltype(from_json(j, std::forward<T>(val)))
template<uint_t side_size>
class FrozenLake : public rlenvscpp::envs::gymnasium::ToyTextEnvBase<TimeStep<uint_t>, frozenlake_state_size<side_size>::size, 4>
#include <frozen_lake_env.h>

The FrozenLake class. Wrapper to Gymnasium FrozenLake environment.

Public Types

typedef std::vector<std::tuple<real_t, uint_t, real_t, bool>> dynamics_t

dynamics_t

typedef ToyTextEnvBase<TimeStep<uint_t>, frozenlake_state_size<side_size>::size, 4>::base_type base_type

The base type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the action to be undertaken in the environment.

Public Functions

FrozenLake(const RESTApiServerWrapper &api_server)

Constructor.

FrozenLake(const RESTApiServerWrapper &api_server, const uint_t cidx, bool slippery)

Constructor.

FrozenLake(const FrozenLake &other)

copy constructor

~FrozenLake() = default

~FrozenLake. Destructor.

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type step(const action_type &action) final override

Step in the environment following the given action.

FrozenLake<side_size> make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline std::string map_type() const noexcept

map_type

Returns:

inline bool is_slippery() const noexcept

is_slipery

Returns:

Public Static Attributes

static const std::string name = "FrozenLake"

name

static const std::string URI = "/gymnasium/frozen-lake-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

build the dynamics from response

Handle the reset response from the environment server

Private Members

bool is_slippery_

is_slipery_

template<uint_t side_size>
struct frozenlake_state_size
template<>
struct frozenlake_state_size<4>

Public Static Attributes

static constexpr uint_t size = 16

size

template<>
struct frozenlake_state_size<8>

Public Static Attributes

static constexpr uint_t size = 64

size

template<typename T, size_t N>
struct Gen

Public Types

using type = typename Extend<typename Gen<T, N / 2>::type, N / 2, N % 2>::type
template<typename T>
struct Gen<T, 0>

Public Types

using type = integer_sequence<T>
template<int dim>
class GenericLine
#include <generic_line.h>

class GenericLine. Represents a generic line with vertex VertexType The equation of a linein l=Ax + By + C

Subclassed by rlenvscpp::utils::trajectory::LineSegmentLink< dim, NodeData, SegmentData >

Public Types

typedef GeomPoint<dim> vertex_type

Public Functions

GenericLine()

Constructor.

GenericLine(const vertex_type &p1, const vertex_type &p2)

Constructor.

GenericLine(const vertex_type &p1, const vertex_type &p2, uint_t id)

Constructor.

const vertex_type &get_vertex(uint_t v) const

Returns the v-th vertex of the segment.

vertex_type &get_vertex(uint_t v)

Returns the v-th vertex of the segment.

inline bool has_valid_id() const noexcept

Returns true iff id_ != rlenvscpp::consts::INVALID_ID.

inline uint_t get_id() const noexcept

Returns the id of the line.

inline void set_id(uint_t id) noexcept

Set the id of the line.

real_t slope() const

The slope of the line.

real_t factor() const

Returns the constant factor.

real_t distance(const vertex_type &n) const

Returns the perpendicular distance from the line to the node.

inline real_t length() const

Calculate the length of the line.

real_t distance(const GenericLine<2>::vertex_type &n) const

Public Static Attributes

static const int dimension = dim

Private Members

uint_t id_
vertex_type start_
vertex_type end_
template<int spacedim, typename T = real_t>
class GeomPoint
#include <geom_point.h>

A class that describes a point with spacedim spatial dimension space.

Subclassed by rlenvscpp::utils::trajectory::WayPoint< dim, Data >

Public Types

typedef T value_type

value_type. The type of the coordinates

Public Functions

inline explicit GeomPoint(T val = T())

ctor all dim data are assigned the given value

template<typename Container>
inline explicit GeomPoint(const Container &data)

Create by passing a vector of data.

GeomPoint(const std::initializer_list<T> &list)

Construct given an initializer_list.

inline GeomPoint(const GeomPoint &t)

copy ctor

inline GeomPoint &operator=(const GeomPoint &t)

copy assignement operator

inline virtual ~GeomPoint()

dtor

inline GeomPoint &operator+=(const GeomPoint&)

Add another vector, i.e. move this point by the given offset.

inline GeomPoint &operator-=(const GeomPoint&)

\detailed Subtract another tensor.

inline GeomPoint &operator*=(T factor)

Scale the point by factor.

inline GeomPoint &operator/=(T factor)

Scale the vector by factor.

inline GeomPoint &operator=(const std::initializer_list<T> &list)

operator = Assign from the initializer list

void scale(T factor)

scale with a given factor

void scale(const std::vector<T> &factors)

scale this object by the given factors p factors should have size at least spacedim

inline void zero()

Zero the entries of the tensor.

inline void add_scaled(const GeomPoint &p, T factor)

Add the coordinates of the given point to this scaled by factor.

inline T &operator[](uint_t i)

Access the i-th coordinate of the point.

inline T operator[](uint_t i) const

Access the i-th coordinate of the point read-only.

inline T entry(uint_t i) const

access the i-th coordinate of the point read-only

inline auto coordinates() const

Get a copy of the data of this object.

T max() const

Get the max element in the point.

T min() const

Get the min element in the point.

T distance(const GeomPoint&) const

Get the distance from the given point.

inline T L2_norm() const

Return the distance from the origin.

T dot(const GeomPoint &other) const

Returns the dot product of this point and the given point.

T square_sum() const

Returns the square sum of the compontents.

inline std::ostream &print_point_info(std::ostream &out) const

print the point

const std::string to_string() const

Returns string representation of the point.

Public Static Attributes

static const int dimension = spacedim

dimension. Spatial dimension of the point

Private Members

std::array<T, spacedim> data_

Hold the coordinates of the point.

template<uint_t side_size_>
class Gridworld : public rlenvscpp::envs::EnvBase<TimeStep<detail::board_state_type>, detail::GridWorldEnv<side_size_>>
#include <grid_world_env.h>

The Gridworld class models a square board. There are three ways to initialize the board.

  • static

  • random

  • player See the GridworldInitType enumeration. Static initialization means that the objects on the board are initialized at the same predetermined locations. Player initialization means that the player is initialized at a random position on the board. Random initialization means that all the objects are placed randomly

Public Types

typedef EnvBase<TimeStep<detail::board_state_type>, detail::GridWorldEnv<side_size_>> base_type

The base_type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the action to be undertaken in the environment.

Public Functions

Gridworld()

Constructor.

explicit Gridworld(const uint_t cidx)

Gridworld. Constructor.

Gridworld(const Gridworld &other)

Gridworld. Constructor.

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type reset(uint_t, const std::unordered_map<std::string, std::any>&) final override

Reset the environment.

Gridworld make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

virtual time_step_type step(const action_type &action) final override

step

Parameters:

action

Returns:

virtual void close() final override

close

inline bool has_random_state() const noexcept

has_random_state

Returns:

inline uint_t n_states() const noexcept

n_states. Returns the number of states

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

inline uint_t seed() const noexcept

seed

Returns:

inline real_t noise_factor() const noexcept

noise_factor

Returns:

bool is_game_lost() const

Returns true if the PLAYER position is the same as the PIT position.

inline GridWorldInitType init_type() const noexcept

init_type

Returns:

Public Static Attributes

static const std::string name = "Gridworld"

name

static const uint_t n_components = 4

n_components

static const uint_t side_size = side_size_

side_size

Private Members

GridWorldInitType init_mode_

init_mode_

bool randomize_state_

randomize_state_

uint_t seed_

seed_

real_t noise_factor_

noise_factor_

detail::board board_

board_

template<uint_t size_size>
struct GridWorldEnv

Public Types

typedef detail::board state_space
typedef detail::board_state_type state_type
typedef ScalarDiscreteSpace<0, 4> action_space

the action space type

typedef action_space::space_item_type action_type

the Action type

Public Static Attributes

static constexpr uint_t STATE_SPACE_SIZE = size_size * size_size

state space size

static constexpr uint_t ACTION_SPACE_SIZE = action_space::size

action space size

template<typename TimeStepType, typename SpaceType>
class GymnasiumEnvBase : public rlenvscpp::envs::EnvBase<TimeStepType, SpaceType>

Subclassed by rlenvscpp::envs::gymnasium::GymnasiumVecEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >, rlenvscpp::envs::gymnasium::ToyTextEnvBase< TimeStep< uint_t >, frozenlake_state_size< side_size >::size, 4 >, rlenvscpp::envs::gymnasium::ToyTextEnvBase< TimeStep< uint_t >, 48, 2 >, rlenvscpp::envs::gymnasium::ToyTextEnvBase< TimeStep< uint_t >, 37, 4 >, rlenvscpp::envs::gymnasium::ToyTextEnvBase< TimeStep< uint_t >, 500, 6 >

Public Types

typedef EnvBase<TimeStepType, SpaceType> base_type

The base_type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the action to be undertaken in the environment.

Public Functions

virtual ~GymnasiumEnvBase()

~GymnasiumEnvBase. Destructor.

virtual bool is_alive() const
virtual void close() override

close the environment

virtual time_step_type reset(uint_t seed, const std::unordered_map<std::string, std::any> &options) override

Reset the environment.

inline const RESTApiServerWrapper &get_api_server() const

Returns read reference to the underlying API server wrapper.

std::string get_url() const

Returns the full path on the server for this environment.

time_step_type reset(uint_t seed, const std::unordered_map<std::string, std::any> &options) = 0

Expose the various reset methods we use from base class.

inline time_step_type reset()

Expose the various reset methods we use from base class.

Protected Functions

GymnasiumEnvBase(const RESTApiServerWrapper &api_server, const uint_t cidx, const std::string &name)

Constructor.

GymnasiumEnvBase(const GymnasiumEnvBase&)

Copy constructor.

inline RESTApiServerWrapper &get_api_server()

read reference to the api server instance

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const = 0

build the time step from the server response

Protected Attributes

RESTApiServerWrapper api_server_

Pointer to the api server that handles the requests.

template<typename VectorTimeStepType, typename SpaceType>
class GymnasiumVecEnvBase : public rlenvscpp::envs::gymnasium::GymnasiumEnvBase<VectorTimeStepType, SpaceType>

Public Types

typedef GymnasiumEnvBase<VectorTimeStepType, SpaceType>::base_type base_type

The base type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

Public Functions

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) = 0

make. Builds the environment.

inline uint_t get_n_envs() const noexcept

Returns the number of environments.

inline void reset_if_any_done(bool flag) noexcept
inline bool get_reset_if_any_done() const noexcept

Protected Functions

GymnasiumVecEnvBase(const RESTApiServerWrapper &api_server, const uint_t cidx, const std::string &name)

Constructor.

GymnasiumVecEnvBase(const GymnasiumVecEnvBase &other)

Private Members

uint_t n_envs_ = {0}
bool reset_if_any_done_ = {false}

Flag indicating that the vector environment is reset if any of the environments is done.

template<uint_t state_size>
class GymWalk : public rlenvscpp::envs::EnvBase<TimeStep<uint_t>, ScalarDiscreteEnv<state_size, 2, 0, 0>>
#include <gym_walk.h>

class GymWalk. Interface for the GymWalk environment

Public Types

typedef EnvBase<TimeStep<uint_t>, ScalarDiscreteEnv<state_size, 2, 0, 0>> base_type
typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

typedef std::vector<std::tuple<real_t, uint_t, real_t, bool>> dynamics_t

dynamics_t

Public Functions

GymWalk(const RESTApiServerWrapper &api_server)

Constructor.

GymWalk(const RESTApiServerWrapper &api_server, const uint_t cidx)

Constructor.

GymWalk(const GymWalk &other)

copy ctor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual bool is_alive() const final override
virtual void close() final override

close the environment

virtual time_step_type step(const action_type &action) final override

step

Parameters:

action

Returns:

virtual time_step_type reset(uint_t seed, const std::unordered_map<std::string, std::any> &options) final override

Reset the environment.

virtual std::unique_ptr<base_type> make_copy(uint_t cidx) const final override

Create a new copy of the environment with the given copy index.

inline uint_t n_states() const noexcept

n_states. Returns the number of states

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

Public Static Attributes

static const std::string name = "GymWalk"

name

static const std::string URI = "/gdrl/gym-walk-env"

The URI for accessing the environment.

Private Functions

dynamics_t build_dynamics_from_response_(const nlohmann::json &response) const

build the dynamics from response

time_step_type create_time_step_from_response_(const nlohmann::json &response) const

Handle the reset response from the environment server.

Private Members

RESTApiServerWrapper api_server_
template<typename BasicJsonType, typename T, typename = void>
struct has_from_json : public std::false_type
template<typename BasicJsonType, typename T>
struct has_from_json<BasicJsonType, T, enable_if_t<!is_basic_json<T>::value>>

Public Types

using serializer = typename BasicJsonType::template json_serializer<T, void>

Public Static Attributes

static constexpr bool value = is_detected_exact<void, from_json_function, serializer, const BasicJsonType&, T&>::value
template<typename T>
struct has_key_compare : public std::integral_constant<bool, is_detected<detect_key_compare, T>::value>
template<typename BasicJsonType, typename T, typename = void>
struct has_non_default_from_json : public std::false_type
template<typename BasicJsonType, typename T>
struct has_non_default_from_json<BasicJsonType, T, enable_if_t<!is_basic_json<T>::value>>

Public Types

using serializer = typename BasicJsonType::template json_serializer<T, void>

Public Static Attributes

static constexpr bool value = is_detected_exact<T, from_json_function, serializer, const BasicJsonType&>::value
template<typename BasicJsonType, typename T, typename = void>
struct has_to_json : public std::false_type
template<typename BasicJsonType, typename T>
struct has_to_json<BasicJsonType, T, enable_if_t<!is_basic_json<T>::value>>

Public Types

using serializer = typename BasicJsonType::template json_serializer<T, void>

Public Static Attributes

static constexpr bool value = is_detected_exact<void, to_json_function, serializer, BasicJsonType&, T>::value
template<>
struct hash<nlohmann::NLOHMANN_BASIC_JSON_TPL>
#include <json.hpp>

hash value for JSON objects

Public Functions

inline std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
struct HttpVersion

Public Members

uint16_t major
uint16_t minor
template<class T>
struct identity_tag
class input_stream_adapter
#include <json.hpp>

Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at beginning of input. Does not support changing the underlying std::streambuf in mid-input. Maintains underlying std::istream and std::streambuf to support subsequent use of standard std::istream operations to process any input characters following those used in parsing the JSON input. Clears the std::istream flags; any input errors (e.g., EOF) will be detected by the first subsequent call for input from the std::istream.

Public Types

using char_type = char

Public Functions

inline ~input_stream_adapter()
inline explicit input_stream_adapter(std::istream &i)
input_stream_adapter(const input_stream_adapter&) = delete
input_stream_adapter &operator=(input_stream_adapter&) = delete
input_stream_adapter &operator=(input_stream_adapter&&) = delete
inline input_stream_adapter(input_stream_adapter &&rhs) noexcept
inline std::char_traits<char>::int_type get_character()

Private Members

std::istream *is = nullptr

the associated input stream

std::streambuf *sb = nullptr
template<typename T, T... Ints>
struct integer_sequence

Public Types

using value_type = T

Public Static Functions

static inline constexpr std::size_t size() noexcept
template<uint_t s, uint_t e>
struct IntegralRange
#include <rlenvs_types_v2.h>

A range of double precision floating point values.

Public Types

typedef uint_t value_type

Public Static Attributes

static constexpr uint_t S = s
static constexpr uint_t E = e
static constexpr uint_t size = e - s
template<typename BasicJsonType>
struct internal_iterator
#include <json.hpp>

an iterator value

Note

This structure could easily be a union, but MSVC currently does not allow unions members with complex constructors, see https://github.com/nlohmann/json/pull/105.

Public Members

BasicJsonType::object_t::iterator object_iterator = {}

iterator for JSON objects

BasicJsonType::array_t::iterator array_iterator = {}

iterator for JSON arrays

primitive_iterator_t primitive_iterator = {}

generic iterator for all other types

class invalid_iterator : public detail::exception
#include <json.hpp>

exception indicating errors with iterators

Public Static Functions

template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
static inline invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)

Private Functions

inline invalid_iterator(int id_, const char *what_arg)
template<typename>
struct is_basic_json : public std::false_type
template<>
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : public std::true_type
template<typename BasicJsonContext>
struct is_basic_json_context : public std::integral_constant<bool, is_basic_json<std::remove_cv<std::remove_pointer<BasicJsonContext>::type>::type>::value || std::is_same<BasicJsonContext, std::nullptr_t>::value>
template<typename T>
struct is_c_string : public bool_constant<impl::is_c_string<T>()>
template<typename Compare, typename A, typename B, typename = void>
struct is_comparable : public std::false_type
template<typename Compare, typename A, typename B>
struct is_comparable<Compare, A, B, void_t<decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())), decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))>> : public std::true_type
template<typename BasicJsonType, typename CompatibleArrayType>
struct is_compatible_array_type : public detail::is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType>
template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
struct is_compatible_array_type_impl : public std::false_type

Subclassed by detail::is_compatible_array_type< BasicJsonType, CompatibleArrayType >

template<typename BasicJsonType, typename CompatibleArrayType>
struct is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType, enable_if_t<is_detected<iterator_t, CompatibleArrayType>::value && is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value && !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value>>

Public Static Attributes

static constexpr bool value = is_constructible<BasicJsonType, range_value_t<CompatibleArrayType>>::value
template<typename RealIntegerType, typename CompatibleNumberIntegerType>
struct is_compatible_integer_type : public detail::is_compatible_integer_type_impl<RealIntegerType, CompatibleNumberIntegerType>
template<typename RealIntegerType, typename CompatibleNumberIntegerType, typename = void>
struct is_compatible_integer_type_impl : public std::false_type

Subclassed by detail::is_compatible_integer_type< RealIntegerType, CompatibleNumberIntegerType >

template<typename RealIntegerType, typename CompatibleNumberIntegerType>
struct is_compatible_integer_type_impl<RealIntegerType, CompatibleNumberIntegerType, enable_if_t<std::is_integral<RealIntegerType>::value && std::is_integral<CompatibleNumberIntegerType>::value && !std::is_same<bool, CompatibleNumberIntegerType>::value>>

Public Types

using RealLimits = std::numeric_limits<RealIntegerType>
using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>

Public Static Attributes

static constexpr auto value = is_constructible<RealIntegerType, CompatibleNumberIntegerType>::value && CompatibleLimits::is_integer && RealLimits::is_signed == CompatibleLimits::is_signed
template<typename BasicJsonType, typename CompatibleObjectType>
struct is_compatible_object_type : public detail::is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType>
template<typename BasicJsonType, typename CompatibleObjectType, typename = void>
struct is_compatible_object_type_impl : public std::false_type

Subclassed by detail::is_compatible_object_type< BasicJsonType, CompatibleObjectType >

template<typename BasicJsonType, typename CompatibleObjectType>
struct is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType, enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value && is_detected<key_type_t, CompatibleObjectType>::value>>

Public Types

using object_t = typename BasicJsonType::object_t

Public Static Attributes

static constexpr bool value = is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value && is_constructible<typename object_t::mapped_type, typename CompatibleObjectType::mapped_type>::value
template<typename BasicJsonType, typename CompatibleStringType>
struct is_compatible_string_type

Public Static Attributes

static constexpr auto value = is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value
template<typename BasicJsonType, typename CompatibleType>
struct is_compatible_type : public detail::is_compatible_type_impl<BasicJsonType, CompatibleType>
template<typename BasicJsonType, typename CompatibleType, typename = void>
struct is_compatible_type_impl : public std::false_type

Subclassed by detail::is_compatible_type< BasicJsonType, CompatibleType >

template<typename BasicJsonType, typename CompatibleType>
struct is_compatible_type_impl<BasicJsonType, CompatibleType, enable_if_t<is_complete_type<CompatibleType>::value>>

Public Static Attributes

static constexpr bool value = has_to_json<BasicJsonType, CompatibleType>::value
template<typename T, typename = void>
struct is_complete_type : public std::false_type
template<typename T>
struct is_complete_type<T, decltype(void(sizeof(T)))> : public std::true_type
template<typename T, typename ...Args>
struct is_constructible : public std::is_constructible<T, Args...>
template<typename T1, typename T2>
struct is_constructible<const std::pair<T1, T2>> : public detail::is_default_constructible<const std::pair<T1, T2>>
template<typename ...Ts>
struct is_constructible<const std::tuple<Ts...>> : public detail::is_default_constructible<const std::tuple<Ts...>>
template<typename T1, typename T2>
struct is_constructible<std::pair<T1, T2>> : public detail::is_default_constructible<std::pair<T1, T2>>
template<typename ...Ts>
struct is_constructible<std::tuple<Ts...>> : public detail::is_default_constructible<std::tuple<Ts...>>
template<typename BasicJsonType, typename ConstructibleArrayType>
struct is_constructible_array_type : public detail::is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType>
template<typename BasicJsonType, typename ConstructibleArrayType, typename = void>
struct is_constructible_array_type_impl : public std::false_type

Subclassed by detail::is_constructible_array_type< BasicJsonType, ConstructibleArrayType >

template<typename BasicJsonType, typename ConstructibleArrayType>
struct is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType, enable_if_t<!std::is_same<ConstructibleArrayType, typename BasicJsonType::value_type>::value && !is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value && is_default_constructible<ConstructibleArrayType>::value && (std::is_move_assignable<ConstructibleArrayType>::value || std::is_copy_assignable<ConstructibleArrayType>::value) && is_detected<iterator_t, ConstructibleArrayType>::value && is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value && is_detected<range_value_t, ConstructibleArrayType>::value && !std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value && is_complete_type<detected_t<range_value_t, ConstructibleArrayType>>::value>>

Public Types

using value_type = range_value_t<ConstructibleArrayType>

Public Static Attributes

static constexpr bool value = std::is_same<value_type, typename BasicJsonType::array_t::value_type>::value || has_from_json<BasicJsonType, value_type>::value || has_non_default_from_json<BasicJsonType, value_type>::value
template<typename BasicJsonType, typename ConstructibleArrayType>
struct is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType, enable_if_t<std::is_same<ConstructibleArrayType, typename BasicJsonType::value_type>::value>> : public std::true_type
template<typename BasicJsonType, typename ConstructibleObjectType>
struct is_constructible_object_type : public detail::is_constructible_object_type_impl<BasicJsonType, ConstructibleObjectType>
template<typename BasicJsonType, typename ConstructibleObjectType, typename = void>
struct is_constructible_object_type_impl : public std::false_type

Subclassed by detail::is_constructible_object_type< BasicJsonType, ConstructibleObjectType >

template<typename BasicJsonType, typename ConstructibleObjectType>
struct is_constructible_object_type_impl<BasicJsonType, ConstructibleObjectType, enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value && is_detected<key_type_t, ConstructibleObjectType>::value>>

Public Types

using object_t = typename BasicJsonType::object_t

Public Static Attributes

static constexpr bool value = (is_default_constructible<ConstructibleObjectType>::value && (std::is_move_assignable<ConstructibleObjectType>::value || std::is_copy_assignable<ConstructibleObjectType>::value) && (is_constructible<typename ConstructibleObjectType::key_type, typename object_t::key_type>::value && std::is_same<typename object_t::mapped_type, typename ConstructibleObjectType::mapped_type>::value)) || (has_from_json<BasicJsonType, typename ConstructibleObjectType::mapped_type>::value || has_non_default_from_json<BasicJsonType, typename ConstructibleObjectType::mapped_type>::value)
template<typename BasicJsonType, typename ConstructibleStringType>
struct is_constructible_string_type

Public Types

using laundered_type = ConstructibleStringType

Public Static Attributes

static constexpr auto value = conjunction<is_constructible<laundered_type, typename BasicJsonType::string_t>, is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, laundered_type>>::value
template<typename T1, typename T2>
struct is_constructible_tuple : public std::false_type
template<typename T1, typename ...Args>
struct is_constructible_tuple<T1, std::tuple<Args...>> : public detail::conjunction<is_constructible<T1, Args>...>
template<typename T>
struct is_default_constructible : public std::is_default_constructible<T>
template<typename T1, typename T2>
struct is_default_constructible<const std::pair<T1, T2>> : public detail::conjunction<is_default_constructible<T1>, is_default_constructible<T2>>

Subclassed by detail::is_constructible< const std::pair< T1, T2 > >

template<typename ...Ts>
struct is_default_constructible<const std::tuple<Ts...>> : public detail::conjunction<is_default_constructible<Ts>...>

Subclassed by detail::is_constructible< const std::tuple< Ts… > >

template<typename T1, typename T2>
struct is_default_constructible<std::pair<T1, T2>> : public detail::conjunction<is_default_constructible<T1>, is_default_constructible<T2>>

Subclassed by detail::is_constructible< std::pair< T1, T2 > >

template<typename ...Ts>
struct is_default_constructible<std::tuple<Ts...>> : public detail::conjunction<is_default_constructible<Ts>...>

Subclassed by detail::is_constructible< std::tuple< Ts… > >

template<template<class...> class Op, class ...Args>
struct is_detected_lazy : public is_detected<Op, Args...>
template<typename BasicJsonType, typename T>
struct is_getable

Public Static Attributes

static constexpr bool value = is_detected<get_template_function, const BasicJsonType&, T>::value
template<typename T>
struct is_iterator_of_multibyte

Public Types

enum [anonymous]

Values:

using value_type = typename std::iterator_traits<T>::value_type
template<typename T, typename = void>
struct is_iterator_traits : public std::false_type
template<typename T>
struct is_iterator_traits<iterator_traits<T>>

Public Static Attributes

static constexpr auto value = is_detected<value_type_t, traits>::value && is_detected<difference_type_t, traits>::value && is_detected<pointer_t, traits>::value && is_detected<iterator_category_t, traits>::value && is_detected<reference_t, traits>::value

Private Types

using traits = iterator_traits<T>
template<typename BasicJsonType, typename T>
struct is_json_iterator_of : public std::false_type
template<typename BasicJsonType>
struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::const_iterator> : public std::true_type
template<typename BasicJsonType>
struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::iterator> : public std::true_type
template<typename>
struct is_json_ref : public std::false_type
template<typename T>
struct is_json_ref<json_ref<T>> : public std::true_type
template<typename T>
struct is_ordered_map

Public Types

enum [anonymous]

Values:

enumerator value
using one = char

Public Static Functions

template<typename C>
static one test(decltype(&C::capacity))
template<typename C>
static two test(...)
template<typename T>
struct is_range

Public Static Attributes

static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin

Private Types

using t_ref = typename std::add_lvalue_reference<T>::type
using iterator = detected_t<result_of_begin, t_ref>
using sentinel = detected_t<result_of_end, t_ref>

Private Static Attributes

static constexpr auto is_iterator_begin = is_iterator_traits<iterator_traits<iterator>>::value
template<typename SAX, typename BasicJsonType>
struct is_sax

Private Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t
using exception_t = typename BasicJsonType::exception
template<typename SAX, typename BasicJsonType>
struct is_sax_static_asserts

Private Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t
using exception_t = typename BasicJsonType::exception
template<template<typename...> class Primary, typename T>
struct is_specialization_of : public std::false_type
template<template<typename...> class Primary, typename ...Args>
struct is_specialization_of<Primary, Primary<Args...>> : public std::true_type
template<typename T>
struct is_transparent : public bool_constant<impl::is_transparent<T>()>
template<typename BasicJsonType>
class iter_impl
#include <json.hpp>

a template for a bidirectional iterator for the basic_json class This class implements a both iterators (iterator and const_iterator) for the basic_json class.

Since

version 1.0.0, simplified in version 2.0.9, change to bidirectional iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)

Note

An iterator is called initialized when a pointer to a JSON value has been set (e.g., by a constructor or a copy assignment). If the iterator is default-constructed, it is uninitialized and most methods are undefined. The library uses assertions to detect calls on uninitialized iterators.** @requirement The class satisfies the following concept requirements:

  • BidirectionalIterator: The iterator that can be moved can be moved in both directions (i.e. incremented and decremented).

Public Types

using iterator_category = std::bidirectional_iterator_tag

The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. The C++ Standard has never required user-defined iterators to derive from std::iterator. A user-defined iterator should provide publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators.

using value_type = typename BasicJsonType::value_type

the type of the values when the iterator is dereferenced

using difference_type = typename BasicJsonType::difference_type

a type to represent differences between iterators

using pointer = typename std::conditional<std::is_const<BasicJsonType>::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer>::type

defines a pointer to the type iterated over (value_type)

using reference = typename std::conditional<std::is_const<BasicJsonType>::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference>::type

defines a reference to the type iterated over (value_type)

Public Functions

iter_impl() = default
~iter_impl() = default
iter_impl(iter_impl&&) noexcept = default
iter_impl &operator=(iter_impl&&) noexcept = default
inline explicit iter_impl(pointer object) noexcept

constructor for a given JSON instance

Parameters:

object[in] pointer to a JSON object for this iterator

Pre:

object != nullptr

Post:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl(const iter_impl<const BasicJsonType> &other) noexcept

const copy constructor

Note

The conventional copy constructor and copy assignment are implicitly defined. Combined with the following converting constructor and assignment, they support: (1) copy from iterator to iterator, (2) copy from const iterator to const iterator, and (3) conversion from iterator to const iterator. However conversion from const iterator to iterator is not defined.

Note

This copy constructor had to be defined explicitly to circumvent a bug occurring on msvc v19.0 compiler (VS 2015) debug build. For more information refer to: https://github.com/nlohmann/json/issues/1608

Parameters:

other[in] const iterator to copy from

inline iter_impl &operator=(const iter_impl<const BasicJsonType> &other) noexcept

converting assignment

Note

It is not checked whether other is initialized.

Parameters:

other[in] const iterator to copy from

Returns:

const/non-const iterator

inline iter_impl(const iter_impl<typename std::remove_const<BasicJsonType>::type> &other) noexcept

converting constructor

Note

It is not checked whether other is initialized.

Parameters:

other[in] non-const iterator to copy from

inline iter_impl &operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type> &other) noexcept

converting assignment

Note

It is not checked whether other is initialized.

Parameters:

other[in] non-const iterator to copy from

Returns:

const/non-const iterator

inline  switch (m_object->m_data.m_type)
inline void set_end() noexcept

set the iterator past the last value

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline reference operator*() const

return a reference to the value pointed to by the iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline pointer operator->() const

dereference the iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl operator++(int) &

post-increment (it++)

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl &operator++()

pre-increment (++it)

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl operator--(int) &

post-decrement (it&#8212;)

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl &operator--()

pre-decrement (&#8212;it)

Pre:

The iterator is initialized; i.e. m_object != nullptr.

template<typename IterImpl, detail::enable_if_t<(std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t> = nullptr>
inline bool operator==(const IterImpl &other) const

comparison: equal

Pre:

The iterator is initialized; i.e. m_object != nullptr.

template<typename IterImpl, detail::enable_if_t<(std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t> = nullptr>
inline bool operator!=(const IterImpl &other) const

comparison: not equal

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline bool operator<(const iter_impl &other) const

comparison: smaller

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline bool operator<=(const iter_impl &other) const

comparison: less than or equal

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline bool operator>(const iter_impl &other) const

comparison: greater than

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline bool operator>=(const iter_impl &other) const

comparison: greater than or equal

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl &operator+=(difference_type i)

add to iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl &operator-=(difference_type i)

subtract from iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl operator+(difference_type i) const

add to iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline iter_impl operator-(difference_type i) const

subtract from iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline difference_type operator-(const iter_impl &other) const

return difference

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline reference operator[](difference_type n) const

access to successor

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline const object_t::key_type &key() const

return the key of an object iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

inline reference value() const

return the value of an iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

Public Members

JSON_PRIVATE_UNLESS_TESTED __pad0__
JSON_PRIVATE_UNLESS_TESTED __pad1__
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it = {}

the actual iterator of the associated instance

Private Types

using other_iter_impl = iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>

the iterator with BasicJsonType of different const-ness

using object_t = typename BasicJsonType::object_t
using array_t = typename BasicJsonType::array_t

Private Members

friend other_iter_impl

allow basic_json to access private members

friend BasicJsonType
friend iteration_proxy< iter_impl >
friend iteration_proxy_value< iter_impl >

Friends

inline friend iter_impl operator+(difference_type i, const iter_impl &it)

addition of distance and iterator

Pre:

The iterator is initialized; i.e. m_object != nullptr.

template<typename IteratorType>
class iteration_proxy
#include <json.hpp>

proxy class for the items() function

Public Functions

explicit iteration_proxy() = default
inline explicit iteration_proxy(typename IteratorType::reference cont) noexcept

construct iteration proxy from a container

iteration_proxy(iteration_proxy const&) = default
iteration_proxy &operator=(iteration_proxy const&) = default
iteration_proxy(iteration_proxy&&) noexcept = default
iteration_proxy &operator=(iteration_proxy&&) noexcept = default
~iteration_proxy() = default
inline iteration_proxy_value<IteratorType> begin() const noexcept

return iterator begin (needed for range-based for)

inline iteration_proxy_value<IteratorType> end() const noexcept

return iterator end (needed for range-based for)

Private Members

IteratorType::pointer container = nullptr

the container to iterate

template<typename IteratorType>
class iteration_proxy_value

Public Types

using difference_type = std::ptrdiff_t
using value_type = iteration_proxy_value
using pointer = value_type*
using reference = value_type&
using iterator_category = std::input_iterator_tag
using string_type = typename std::remove_cv<typename std::remove_reference<decltype(std::declval<IteratorType>().key())>::type>::type

Public Functions

explicit iteration_proxy_value() = default
inline explicit iteration_proxy_value(IteratorType it, std::size_t array_index_ = 0) noexcept(std::is_nothrow_move_constructible<IteratorType>::value && std::is_nothrow_default_constructible<string_type>::value)
iteration_proxy_value(iteration_proxy_value const&) = default
iteration_proxy_value &operator=(iteration_proxy_value const&) = default
iteration_proxy_value(iteration_proxy_value&&) noexcept(std::is_nothrow_move_constructible<IteratorType>::value && std::is_nothrow_move_constructible<string_type>::value) = default
iteration_proxy_value &operator=(iteration_proxy_value&&) noexcept(std::is_nothrow_move_assignable<IteratorType>::value && std::is_nothrow_move_assignable<string_type>::value) = default
~iteration_proxy_value() = default
inline const iteration_proxy_value &operator*() const

dereference operator (needed for range-based for)

inline iteration_proxy_value &operator++()

increment operator (needed for range-based for)

inline iteration_proxy_value operator++(int) &
inline bool operator==(const iteration_proxy_value &o) const

equality operator (needed for InputIterator)

inline bool operator!=(const iteration_proxy_value &o) const

inequality operator (needed for range-based for)

inline const string_type &key() const

return key of the iterator

inline IteratorType::reference value() const

return value of the iterator

Private Members

IteratorType anchor = {}

the iterator

std::size_t array_index = 0

an index for arrays (used to create key names)

mutable std::size_t array_index_last = 0

last stringified array index

mutable string_type array_index_str = "0"

a string representation of the array index

string_type empty_str = {}

an empty string (to return a reference for primitive values)

class IterationCounter

The IterationCounter class.

Public Functions

inline explicit IterationCounter(uint_t max_itrs) noexcept

IterationCounter.

Parameters:

max_iterations

inline bool continue_iterations() noexcept

continue_iterations

Returns:

inline uint_t current_iteration_index() const noexcept

current_iteration_index

Returns:

inline uint_t max_iterations() const noexcept

max_iterations

Returns:

Private Members

uint_t current_itr_index_

current_itr_index_

uint_t max_iterations_

max_iterations_

class IterativeAlgorithmController

Controller for iterative algorithms.

Public Functions

inline IterativeAlgorithmController(uint_t maxIterations, real_t exitTolerance)

Constructor.

IterativeAlgorithmController(const IterativeAlgorithmController&) = default

Copy constructor.

IterativeAlgorithmController(IterativeAlgorithmController&&) = default

Move copy constructor.

IterativeAlgorithmController &operator=(const IterativeAlgorithmController&) = default

copy assignement

IterativeAlgorithmController &operator=(IterativeAlgorithmController&&) = default

move copy assignement

~IterativeAlgorithmController() = default

Destructor.

bool continue_iterations()

Returns true if the iterations of the algorithm should be continued.

inline bool show_iterations() const

show iterations

inline bool track_residuals() const

track_residuals

Returns:

inline void set_tolerance(real_t tol)

set_tolerance

Parameters:

tol

inline void set_show_iterations_flag(bool flag)

show iterations

inline void set_track_residuals_flag(bool flag)

set_track_residuals_flag

Parameters:

flag

inline void set_num_threads(uint_t nthreads)

Set the number of threads.

inline void set_max_itrs(uint_t max_itrs)

set_max_itrs

Parameters:

max_itrs

inline uint_t get_current_iteration() const

Returns the current iteration index.

inline real_t get_exit_tolerance() const

Returns the exit tolerance for the algorithm.

inline uint_t get_max_iterations() const

Return the maximum number of iterations.

inline uint_t get_num_threads() const

Get the number of threads used.

inline real_t get_residual() const

get_residual

Returns:

IterativeAlgorithmResult get_state() const

Returns the state of the controller.

inline void update_residual(real_t res)

Update the residual.

void reset(const IterativeAlgorithmController &control)

reset

void reset()

reset

Private Members

uint_t max_iterations_
real_t exit_tolerance_
uint_t current_iteration_idx_
uint_t n_threads_
real_t current_res_
bool show_iterations_
bool track_residuals_
struct IterativeAlgorithmResult

The IterativeAlgorithmResult struct. Helper struct to assemble the result of an iterative algorithm.

Public Functions

IterativeAlgorithmResult() = default

IterativeAlgorithmResult.

IterativeAlgorithmResult(real_t tol, real_t res, uint_t nitrs, std::chrono::duration<real_t> time)

IterativeAlgorithmResult.

std::ostream &print(std::ostream &out) const

print

Public Members

real_t tolerance

tolerance

real_t residual

residual

uint_t num_iterations

num_iterations

bool converged = false

converged

std::chrono::duration<real_t> total_time

total_time

std::vector<real_t> residuals

residuals

template<typename IteratorType>
class iterator_input_adapter

Public Types

using char_type = typename std::iterator_traits<IteratorType>::value_type

Public Functions

inline iterator_input_adapter(IteratorType first, IteratorType last)
inline char_traits<char_type>::int_type get_character()

Private Functions

inline bool empty() const

Private Members

IteratorType current
IteratorType end

Friends

friend struct wide_string_input_helper
template<typename IteratorType, typename Enable = void>
struct iterator_input_adapter_factory

Public Types

using iterator_type = IteratorType
using char_type = typename std::iterator_traits<iterator_type>::value_type
using adapter_type = iterator_input_adapter<iterator_type>

Public Static Functions

static inline adapter_type create(IteratorType first, IteratorType last)
template<typename IteratorType>
struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>::value>>

Public Types

using iterator_type = IteratorType
using char_type = typename std::iterator_traits<iterator_type>::value_type
using base_adapter_type = iterator_input_adapter<iterator_type>
using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>

Public Static Functions

static inline adapter_type create(IteratorType first, IteratorType last)
template<typename T, typename = void>
struct iterator_traits
template<typename T>
struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>

Public Types

using iterator_category = std::random_access_iterator_tag
using value_type = T
using difference_type = ptrdiff_t
using pointer = T*
using reference = T&
template<typename T>
struct iterator_traits<T, enable_if_t<!std::is_pointer<T>::value>> : public detail::iterator_types<T>
template<typename It, typename = void>
struct iterator_types
template<typename It>
struct iterator_types<It, void_t<typename It::difference_type, typename It::value_type, typename It::pointer, typename It::reference, typename It::iterator_category>>

Public Types

using difference_type = typename It::difference_type
using value_type = typename It::value_type
using pointer = typename It::pointer
using reference = typename It::reference
using iterator_category = typename It::iterator_category
struct json_default_base
#include <json.hpp>

Default base class of the basic_json class.

So that the correct implementations of the copy / move ctors / assign operators of basic_json do not require complex case distinctions (no base class / custom base class used as customization point), basic_json always has a base class. By default, this class is used because it is empty and thus has no effect on the behavior of basic_json.

template<typename RefStringType>
class json_pointer
#include <json.hpp>

JSON Pointer defines a string syntax for identifying a specific value within a JSON document.

Public Types

using string_t = typename string_t_helper<RefStringType>::type

Public Functions

inline explicit json_pointer(const string_t &s = "")

create JSON pointer

inline string_t to_string() const

return a string representation of the JSON pointer

inline operator string_t() const

return a string representation of the JSON pointer

inline json_pointer &operator/=(const json_pointer &ptr)

append another JSON pointer at the end of this JSON pointer

inline json_pointer &operator/=(string_t token)

append an unescaped reference token at the end of this JSON pointer

inline json_pointer &operator/=(std::size_t array_idx)

append an array index at the end of this JSON pointer

inline json_pointer parent_pointer() const

returns the parent of this JSON pointer

inline void pop_back()

remove last reference token

inline const string_t &back() const

return last reference token

inline void push_back(const string_t &token)

append an unescaped token at the end of the reference pointer

inline void push_back(string_t &&token)

append an unescaped token at the end of the reference pointer

inline bool empty() const noexcept

return whether pointer points to the root document

Private Functions

template<typename BasicJsonType>
inline BasicJsonType &get_and_create(BasicJsonType &j) const

create and return a reference to the pointed to value

@complexity Linear in the number of reference tokens.

Throws:
  • parse_error.109 – if array index is not a number

  • type_error.313 – if value cannot be unflattened

template<typename BasicJsonType>
inline BasicJsonType &get_unchecked(BasicJsonType *ptr) const

return a reference to the pointed to value

@complexity Linear in the length of the JSON pointer.

Note

This version does not throw if a value is not present, but tries to create nested values instead. For instance, calling this function with pointer "/this/that" on a null value is equivalent to calling operator[]("this").operator[]("that") on that value, effectively changing the null value to an object.

Parameters:

ptr[in] a JSON value

Returns:

reference to the JSON value pointed to by the JSON pointer

Throws:
  • parse_error.106 – if an array index begins with ‘0’

  • parse_error.109 – if an array index was not a number

  • out_of_range.404 – if the JSON pointer can not be resolved

template<typename BasicJsonType>
inline BasicJsonType &get_checked(BasicJsonType *ptr) const
Throws:
  • parse_error.106 – if an array index begins with ‘0’

  • parse_error.109 – if an array index was not a number

  • out_of_range.402 – if the array index ‘-’ is used

  • out_of_range.404 – if the JSON pointer can not be resolved

template<typename BasicJsonType>
inline const BasicJsonType &get_unchecked(const BasicJsonType *ptr) const

return a const reference to the pointed to value

Parameters:

ptr[in] a JSON value

Throws:
  • parse_error.106 – if an array index begins with ‘0’

  • parse_error.109 – if an array index was not a number

  • out_of_range.402 – if the array index ‘-’ is used

  • out_of_range.404 – if the JSON pointer can not be resolved

Returns:

const reference to the JSON value pointed to by the JSON pointer

template<typename BasicJsonType>
inline const BasicJsonType &get_checked(const BasicJsonType *ptr) const
Throws:
  • parse_error.106 – if an array index begins with ‘0’

  • parse_error.109 – if an array index was not a number

  • out_of_range.402 – if the array index ‘-’ is used

  • out_of_range.404 – if the JSON pointer can not be resolved

template<typename BasicJsonType>
inline bool contains(const BasicJsonType *ptr) const
Throws:
  • parse_error.106 – if an array index begins with ‘0’

  • parse_error.109 – if an array index was not a number

inline json_pointer<string_t> convert() const &
inline json_pointer<string_t> convert() &&

Private Members

JSON_PRIVATE_UNLESS_TESTED __pad0__
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no parent
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no nullptr
json_pointer result = *this
result reference_tokens = {reference_tokens[0]}
return result
std::vector<string_t> reference_tokens

the reference tokens

Private Static Functions

template<typename BasicJsonType>
static inline BasicJsonType::size_type array_index(const string_t &s)
Parameters:

s[in] reference token to be converted into an array index

Throws:
  • parse_error.106 – if an array index begins with ‘0’

  • parse_error.109 – if an array index begins not with a digit

  • out_of_range.404 – if string s could not be converted to an integer

  • out_of_range.410 – if an array index exceeds size_type

Returns:

integer representation of s

static inline std::vector<string_t> split(const string_t &reference_string)

split the string input to reference tokens

Note

This function is only called by the json_pointer constructor. All exceptions below are documented there.

Throws:
  • parse_error.107 – if the pointer is not empty or begins with ‘/’

  • parse_error.108 – if character ‘~’ is not followed by ‘0’ or ‘1’

template<typename BasicJsonType>
static inline void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)

Note

Empty objects or arrays are flattened to null.

Parameters:
  • reference_string[in] the reference string to the current value

  • value[in] the value to consider

  • result[inout] the result object to insert values to

template<typename BasicJsonType>
static inline BasicJsonType unflatten(const BasicJsonType &value)
Parameters:

value[in] flattened JSON

Throws:
  • parse_error.109 – if array index is not a number

  • type_error.314 – if value is not an object

  • type_error.315 – if object values are not primitive

  • type_error.313 – if value cannot be unflattened

Returns:

unflattened JSON

Friends

friend class basic_json
friend class json_pointer
inline friend std::ostream &operator<<(std::ostream &o, const json_pointer &ptr)

write string representation of the JSON pointer to stream

inline friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)

create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer

inline friend json_pointer operator/(const json_pointer &lhs, string_t token)

create a new JSON pointer by appending the unescaped token at the end of the JSON pointer

inline friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)

create a new JSON pointer by appending the array-index-token at the end of the JSON pointer

template<typename RefStringTypeLhs, typename RefStringTypeRhs>
friend bool operator==(const json_pointer<RefStringTypeLhs> &lhs, const json_pointer<RefStringTypeRhs> &rhs) noexcept

compares two JSON pointers for equality

template<typename RefStringTypeLhs, typename StringType>
friend bool operator==(const json_pointer<RefStringTypeLhs> &lhs, const StringType &rhs)

compares JSON pointer and string for equality

template<typename RefStringTypeRhs, typename StringType>
friend bool operator==(const StringType &lhs, const json_pointer<RefStringTypeRhs> &rhs)

compares string and JSON pointer for equality

template<typename RefStringTypeLhs, typename RefStringTypeRhs>
friend bool operator!=(const json_pointer<RefStringTypeLhs> &lhs, const json_pointer<RefStringTypeRhs> &rhs) noexcept

compares two JSON pointers for inequality

template<typename RefStringTypeLhs, typename StringType>
friend bool operator!=(const json_pointer<RefStringTypeLhs> &lhs, const StringType &rhs)

compares JSON pointer and string for inequality

template<typename RefStringTypeRhs, typename StringType>
friend bool operator!=(const StringType &lhs, const json_pointer<RefStringTypeRhs> &rhs)

compares string and JSON pointer for inequality

template<typename RefStringTypeLhs, typename RefStringTypeRhs>
friend bool operator<(const json_pointer<RefStringTypeLhs> &lhs, const json_pointer<RefStringTypeRhs> &rhs) noexcept

compares two JSON pointer for less-than

template<typename BasicJsonType>
class json_ref

Public Types

using value_type = BasicJsonType

Public Functions

inline json_ref(value_type &&value)
inline json_ref(const value_type &value)
inline json_ref(std::initializer_list<json_ref> init)
template<class ...Args, enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0>
inline json_ref(Args&&... args)
json_ref(json_ref&&) noexcept = default
json_ref(const json_ref&) = delete
json_ref &operator=(const json_ref&) = delete
json_ref &operator=(json_ref&&) = delete
~json_ref() = default
inline value_type moved_or_copied() const
inline value_type const &operator*() const
inline value_type const *operator->() const

Private Members

mutable value_type owned_value = nullptr
value_type const *value_ref = nullptr
template<typename Base>
class json_reverse_iterator : public std::reverse_iterator<Base>
#include <json.hpp>

a template for a reverse iterator class

@requirement The class satisfies the following concept requirements:

  • BidirectionalIterator: The iterator that can be moved can be moved in both directions (i.e. incremented and decremented).

  • OutputIterator: It is possible to write to the pointed-to element (only if Base is iterator).

Since

version 1.0.0

Template Parameters:

Base – the base iterator type to reverse. Valid types are iterator (to create reverse_iterator) and const_iterator (to create const_reverse_iterator).

Public Types

using difference_type = std::ptrdiff_t
using base_iterator = std::reverse_iterator<Base>

shortcut to the reverse iterator adapter

using reference = typename Base::reference

the reference type for the pointed-to element

Public Functions

inline explicit json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept

create reverse iterator from iterator

inline explicit json_reverse_iterator(const base_iterator &it) noexcept

create reverse iterator from base class

inline json_reverse_iterator operator++(int) &

post-increment (it++)

inline json_reverse_iterator &operator++()

pre-increment (++it)

inline json_reverse_iterator operator--(int) &

post-decrement (it&#8212;)

inline json_reverse_iterator &operator--()

pre-decrement (&#8212;it)

inline json_reverse_iterator &operator+=(difference_type i)

add to iterator

inline json_reverse_iterator operator+(difference_type i) const

add to iterator

inline json_reverse_iterator operator-(difference_type i) const

subtract from iterator

inline difference_type operator-(const json_reverse_iterator &other) const

return difference

inline reference operator[](difference_type n) const

access to successor

inline auto key() const -> decltype(std::declval<Base>().key())

return the key of an object iterator

inline reference value() const

return the value of an iterator

template<typename BasicJsonType>
struct json_sax
#include <json.hpp>

SAX interface.

This class describes the SAX interface used by nlohmann::json::sax_parse. Each function is called in different situations while the input is parsed. The boolean return value informs the parser whether to continue processing the input.

Public Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t

Public Functions

virtual bool null() = 0

a null value was read

Returns:

whether parsing should proceed

virtual bool boolean(bool val) = 0

a boolean value was read

Parameters:

val[in] boolean value

Returns:

whether parsing should proceed

virtual bool number_integer(number_integer_t val) = 0

an integer number was read

Parameters:

val[in] integer value

Returns:

whether parsing should proceed

virtual bool number_unsigned(number_unsigned_t val) = 0

an unsigned integer number was read

Parameters:

val[in] unsigned integer value

Returns:

whether parsing should proceed

virtual bool number_float(number_float_t val, const string_t &s) = 0

a floating-point number was read

Parameters:
  • val[in] floating-point value

  • s[in] raw token value

Returns:

whether parsing should proceed

virtual bool string(string_t &val) = 0

a string value was read

Note

It is safe to move the passed string value.

Parameters:

val[in] string value

Returns:

whether parsing should proceed

virtual bool binary(binary_t &val) = 0

a binary value was read

Note

It is safe to move the passed binary value.

Parameters:

val[in] binary value

Returns:

whether parsing should proceed

virtual bool start_object(std::size_t elements) = 0

the beginning of an object was read

Note

binary formats may report the number of elements

Parameters:

elements[in] number of object elements or -1 if unknown

Returns:

whether parsing should proceed

virtual bool key(string_t &val) = 0

an object key was read

Note

It is safe to move the passed string.

Parameters:

val[in] object key

Returns:

whether parsing should proceed

virtual bool end_object() = 0

the end of an object was read

Returns:

whether parsing should proceed

virtual bool start_array(std::size_t elements) = 0

the beginning of an array was read

Note

binary formats may report the number of elements

Parameters:

elements[in] number of array elements or -1 if unknown

Returns:

whether parsing should proceed

virtual bool end_array() = 0

the end of an array was read

Returns:

whether parsing should proceed

virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex) = 0

a parse error occurred

Parameters:
  • position[in] the position in the input where the error occurs

  • last_token[in] the last read token

  • ex[in] an exception object describing the error

Returns:

whether parsing should proceed (must return false)

json_sax() = default
json_sax(const json_sax&) = default
json_sax(json_sax&&) noexcept = default
json_sax &operator=(const json_sax&) = default
json_sax &operator=(json_sax&&) noexcept = default
virtual ~json_sax() = default
template<typename BasicJsonType>
class json_sax_acceptor

Public Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t

Public Functions

inline bool null()
inline bool boolean(bool)
inline bool number_integer(number_integer_t)
inline bool number_unsigned(number_unsigned_t)
inline bool number_float(number_float_t, const string_t&)
inline bool string(string_t&)
inline bool binary(binary_t&)
inline bool start_object(std::size_t = static_cast<std::size_t>(-1))
inline bool key(string_t&)
inline bool end_object()
inline bool start_array(std::size_t = static_cast<std::size_t>(-1))
inline bool end_array()
inline bool parse_error(std::size_t, const std::string&, const detail::exception&)
template<typename BasicJsonType>
class json_sax_dom_callback_parser

Public Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t
using parser_callback_t = typename BasicJsonType::parser_callback_t
using parse_event_t = typename BasicJsonType::parse_event_t

Public Functions

inline json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_ = true)
json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete
json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default
json_sax_dom_callback_parser &operator=(const json_sax_dom_callback_parser&) = delete
json_sax_dom_callback_parser &operator=(json_sax_dom_callback_parser&&) = default
~json_sax_dom_callback_parser() = default
inline bool null()
inline bool boolean(bool val)
inline bool number_integer(number_integer_t val)
inline bool number_unsigned(number_unsigned_t val)
inline bool number_float(number_float_t val, const string_t&)
inline bool string(string_t &val)
inline bool binary(binary_t &val)
inline bool start_object(std::size_t len)
inline bool key(string_t &val)
inline bool end_object()
inline bool start_array(std::size_t len)
inline bool end_array()
template<class Exception>
inline bool parse_error(std::size_t, const std::string&, const Exception &ex)
inline constexpr bool is_errored() const

Private Functions

template<typename Value>
inline std::pair<bool, BasicJsonType*> handle_value(Value &&v, const bool skip_callback = false)

Invariant

If the ref stack is empty, then the passed value will be the new root.

Invariant

If the ref stack contains a value, then it is an array or an object to which we can add elements

Parameters:
  • v[in] value to add to the JSON value we build during parsing

  • skip_callback[in] whether we should skip calling the callback function; this is required after start_array() and start_object() SAX events, because otherwise we would call the callback function with an empty array or object, respectively.

Returns:

pair of boolean (whether value should be kept) and pointer (to the passed value in the ref_stack hierarchy; nullptr if not kept)

Private Members

BasicJsonType &root

the parsed JSON value

std::vector<BasicJsonType*> ref_stack = {}

stack to model hierarchy of values

std::vector<bool> keep_stack = {}

stack to manage which values to keep

std::vector<bool> key_keep_stack = {}

stack to manage which object keys to keep

BasicJsonType *object_element = nullptr

helper to hold the reference for the next object element

bool errored = false

whether a syntax error occurred

const parser_callback_t callback = nullptr

callback function

const bool allow_exceptions = true

whether to throw exceptions in case of errors

BasicJsonType discarded = BasicJsonType::value_t::discarded

a discarded value for the callback

template<typename BasicJsonType>
class json_sax_dom_parser
#include <json.hpp>

SAX implementation to create a JSON value from SAX events.

This class implements the json_sax interface and processes the SAX events to create a JSON value which makes it basically a DOM parser. The structure or hierarchy of the JSON value is managed by the stack ref_stack which contains a pointer to the respective array or object for each recursion depth.

After successful parsing, the value that is passed by reference to the constructor contains the parsed value.

Template Parameters:

BasicJsonType – the JSON type

Public Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using binary_t = typename BasicJsonType::binary_t

Public Functions

inline explicit json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_ = true)
Parameters:
  • r[inout] reference to a JSON value that is manipulated while parsing

  • allow_exceptions_[in] whether parse errors yield exceptions

json_sax_dom_parser(const json_sax_dom_parser&) = delete
json_sax_dom_parser(json_sax_dom_parser&&) = default
json_sax_dom_parser &operator=(const json_sax_dom_parser&) = delete
json_sax_dom_parser &operator=(json_sax_dom_parser&&) = default
~json_sax_dom_parser() = default
inline bool null()
inline bool boolean(bool val)
inline bool number_integer(number_integer_t val)
inline bool number_unsigned(number_unsigned_t val)
inline bool number_float(number_float_t val, const string_t&)
inline bool string(string_t &val)
inline bool binary(binary_t &val)
inline bool start_object(std::size_t len)
inline bool key(string_t &val)
inline bool end_object()
inline bool start_array(std::size_t len)
inline bool end_array()
template<class Exception>
inline bool parse_error(std::size_t, const std::string&, const Exception &ex)
inline constexpr bool is_errored() const

Private Functions

template<typename Value> inline JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value (Value &&v)

Invariant

If the ref stack is empty, then the passed value will be the new root.

Invariant

If the ref stack contains a value, then it is an array or an object to which we can add elements

Private Members

BasicJsonType &root

the parsed JSON value

std::vector<BasicJsonType*> ref_stack = {}

stack to model hierarchy of values

BasicJsonType *object_element = nullptr

helper to hold the reference for the next object element

bool errored = false

whether a syntax error occurred

const bool allow_exceptions = true

whether to throw exceptions in case of errors

class JSONFileReader : public rlenvscpp::utils::io::FileReaderBase
#include <json_file_reader.h>

Todo:

write docs

Public Functions

JSONFileReader(const std::string &filename)
virtual void open() final override

Attempts to open the file for reading.

template<typename T>
T get_value(const std::string &label) const

Get the value specified by the label.

Private Types

using json = nlohmann::json

Private Members

json data_
template<>
struct less<::nlohmann::detail::value_t>

Public Functions

inline bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept

compare two value_t enum values

Since

version 3.0.0

template<typename BasicJsonType, typename InputAdapterType>
class lexer : public detail::lexer_base<BasicJsonType>
#include <json.hpp>

lexical analysis

This class organizes the lexical analysis during JSON deserialization.

Public Types

using token_type = typename lexer_base<BasicJsonType>::token_type

Public Functions

inline explicit lexer(InputAdapterType &&adapter, bool ignore_comments_ = false) noexcept
lexer(const lexer&) = delete
lexer(lexer&&) = default
lexer &operator=(lexer&) = delete
lexer &operator=(lexer&&) = default
~lexer() = default
inline constexpr number_integer_t get_number_integer() const noexcept

return integer value

inline constexpr number_unsigned_t get_number_unsigned() const noexcept

return unsigned integer value

inline constexpr number_float_t get_number_float() const noexcept

return floating-point value

inline string_t &get_string()

return current string value (implicitly resets the token; useful only once)

inline constexpr position_t get_position() const noexcept

return position of last read token

inline std::string get_token_string() const

return the last read token (for errors only). Will never contain EOF (an arbitrary value that is not a valid char value, often -1), because 255 may legitimately occur. May contain NUL, which should be escaped.

inline constexpr JSON_HEDLEY_RETURNS_NON_NULL const char * get_error_message () const noexcept

return syntax error message

inline bool skip_bom()

skip the UTF-8 byte order mark

Returns:

true iff there is no BOM or the correct BOM has been skipped

inline void skip_whitespace()
inline token_type scan()

Private Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using char_type = typename InputAdapterType::char_type
using char_int_type = typename char_traits<char_type>::int_type

Private Functions

inline int get_codepoint()

get codepoint from 4 hex characters following \u

For input “\u c1 c2 c3 c4” the codepoint is: (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0)

Furthermore, the possible characters ‘0’..’9’, ‘A’..’F’, and ‘a’..’f’ must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The conversion is done by subtracting the offset (0x30, 0x37, and 0x57) between the ASCII value of the character and the desired integer value.

Returns:

codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or non-hex character)

inline bool next_byte_in_range(std::initializer_list<char_int_type> ranges)

check if the next byte(s) are inside a given range

Adds the current byte and, for each passed range, reads a new byte and checks if it is inside the range. If a violation was detected, set up an error message and return false. Otherwise, return true.

Parameters:

ranges[in] list of integers; interpreted as list of pairs of inclusive lower and upper bound, respectively

Pre:

The passed list ranges must have 2, 4, or 6 elements; that is, 1, 2, or 3 pairs. This precondition is enforced by an assertion.

Returns:

true if and only if no range violation was detected

inline token_type scan_string()

scan a string literal

This function scans a string according to Sect. 7 of RFC 8259. While scanning, bytes are escaped and copied into buffer token_buffer. Then the function returns successfully, token_buffer is not null-terminated (as it may contain \0 bytes), and token_buffer.size() is the number of bytes in the string.

Note

In case of errors, variable error_message contains a textual description.

Returns:

token_type::value_string if string could be successfully scanned, token_type::parse_error otherwise

inline bool scan_comment()

scan a comment

Returns:

whether comment could be scanned successfully

inline token_type scan_number()

scan a number literal

This function scans a string according to Sect. 6 of RFC 8259.

The function is realized with a deterministic finite state machine derived from the grammar described in RFC 8259. Starting in state “init”, the input is read and used to determined the next state. Only state “done” accepts the number. State “error” is a trap state to model errors. In the table below, “anything” means any character but the ones listed before.

state

0

1-9

e E

+

-

.

anything

init

zero

any1

[error]

[error]

minus

[error]

[error]

minus

zero

any1

[error]

[error]

[error]

[error]

[error]

zero

done

done

exponent

done

done

decimal1

done

any1

any1

any1

exponent

done

done

decimal1

done

decimal1

decimal2

decimal2

[error]

[error]

[error]

[error]

[error]

decimal2

decimal2

decimal2

exponent

done

done

done

done

exponent

any2

any2

[error]

sign

sign

[error]

[error]

sign

any2

any2

[error]

[error]

[error]

[error]

[error]

any2

any2

any2

done

done

done

done

done

The state machine is realized with one label per state (prefixed with “scan_number_”) and goto statements between them. The state machine contains cycles, but any cycle can be left when EOF is read. Therefore, the function is guaranteed to terminate.

During scanning, the read bytes are stored in token_buffer. This string is then converted to a signed integer, an unsigned integer, or a floating-point number.

Note

The scanner is independent of the current locale. Internally, the locale’s decimal point is used instead of . to work with the locale-dependent converters.

Returns:

token_type::value_unsigned, token_type::value_integer, or token_type::value_float if number could be successfully scanned, token_type::parse_error otherwise

inline token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
Parameters:
  • literal_text[in] the literal text to expect

  • length[in] the length of the passed literal text

  • return_type[in] the token type to return on success

inline void reset() noexcept

reset token_buffer; current character is beginning of token

inline char_int_type get()
inline void unget()

unget current character (read it again on next get)

We implement unget by setting variable next_unget to true. The input is not changed - we just simulate ungetting by modifying chars_read_total, chars_read_current_line, and token_string. The next call to get() will behave as if the unget character is read again.

inline void add(char_int_type c)

add a character to token_buffer

Private Members

InputAdapterType ia

input adapter

const bool ignore_comments = false

whether comments should be ignored (true) or signaled as errors (false)

char_int_type current = char_traits<char_type>::eof()

the current character

bool next_unget = false

whether the next get() call should just return current

position_t position = {}

the start position of the current token

std::vector<char_type> token_string = {}

raw input token string (for error messages)

string_t token_buffer = {}

buffer for variable-length tokens (numbers, strings)

const char *error_message = ""

a description of occurred lexer errors

number_integer_t value_integer = 0
number_unsigned_t value_unsigned = 0
number_float_t value_float = 0
const char_int_type decimal_point_char = '.'

the decimal point

Private Static Functions

static inline JSON_HEDLEY_PURE char get_decimal_point () noexcept

return the locale-dependent decimal point

static inline void strtof(float &f, const char *str, char **endptr) noexcept
static inline void strtof(double &f, const char *str, char **endptr) noexcept
static inline void strtof(long double &f, const char *str, char **endptr) noexcept
template<typename BasicJsonType>
class lexer_base

Subclassed by detail::lexer< BasicJsonType, InputAdapterType >

Public Types

enum class token_type

token types for the parser

Values:

enumerator uninitialized

indicating the scanner is uninitialized

enumerator literal_true

the true literal

enumerator literal_false

the false literal

enumerator literal_null

the null literal

enumerator value_string

a string &#8212; use get_string() for actual value

enumerator value_unsigned

an unsigned integer &#8212; use get_number_unsigned() for actual value

enumerator value_integer

a signed integer &#8212; use get_number_integer() for actual value

enumerator value_float

an floating point number &#8212; use get_number_float() for actual value

enumerator begin_array

the character for array begin [

enumerator begin_object

the character for object begin {

enumerator end_array

the character for array end ]

enumerator end_object

the character for object end }

enumerator name_separator

the name separator :

enumerator value_separator

the value separator ,

enumerator parse_error

indicating a parse error

enumerator end_of_input

indicating the end of the input buffer

enumerator literal_or_value

a literal or the begin of a value (only for diagnostics)

Public Static Functions

static inline JSON_HEDLEY_RETURNS_NON_NULL JSON_HEDLEY_CONST const char * token_type_name (const token_type t) noexcept

return name of values of type token_type (only used for errors)

template<int dim, typename NodeData, typename SegmentData>
class LineSegmentLink : private rlenvscpp::utils::geom::GenericLine<dim>

class LineSegmentLink. Represents a straight line link between two waypoints.

Public Types

typedef NodeData node_data_type
typedef SegmentData segment_data_type
typedef WayPoint<dim, NodeData> w_point_type

Public Functions

LineSegmentLink()

Default ctor.

LineSegmentLink(const w_point_type &v1, const w_point_type &v2, uint_t id, const segment_data_type &data)

Constructor.

LineSegmentLink(const w_point_type &v1, const w_point_type &v2, uint_t id)

Constructor.

inline bool is_active() const

Returns true if the segment is active.

inline void deactivate()

deactive the segment

inline void make_active()

Activate the segment.

Public Static Attributes

static const int dimension = dim

Private Members

std::vector<w_point_type> internal_points_

list of internal points of the segment.

segment_data_type data_

The data asociated with the segmen.

bool is_active_

Flag indicating if the segment is active.

template<typename ...Ts>
struct make_void

Public Types

using type = void
template<typename Enum, typename T, typename Compare = map_compare<T>>
struct map

Public Types

typedef T (*function)(Enum)

Public Functions

inline explicit BETTER_ENUMS_CONSTEXPR_ map(function f)
inline BETTER_ENUMS_CONSTEXPR_ T from_enum (Enum value) const
inline BETTER_ENUMS_CONSTEXPR_ T operator[] (Enum value) const
inline BETTER_ENUMS_CONSTEXPR_ Enum to_enum (T value) const
inline BETTER_ENUMS_CONSTEXPR_ optional< Enum > to_enum_nothrow (T value, size_t index=0) const

Private Members

const function _f
template<typename T>
struct map_compare

Public Static Functions

static inline BETTER_ENUMS_CONSTEXPR_ bool less (const T &a, const T &b)
template<>
struct map_compare<const char*>

Public Static Functions

static inline BETTER_ENUMS_CONSTEXPR_ bool less (const char *a, const char *b)

Private Static Functions

static inline BETTER_ENUMS_CONSTEXPR_ bool less_loop (const char *a, const char *b, size_t index=0)
template<>
struct map_compare<const wchar_t*>

Public Static Functions

static inline BETTER_ENUMS_CONSTEXPR_ bool less (const wchar_t *a, const wchar_t *b)

Private Static Functions

static inline BETTER_ENUMS_CONSTEXPR_ bool less_loop (const wchar_t *a, const wchar_t *b, size_t index=0)
template<typename StateTp, typename MatrixDescriptor, typename InputTp>
class MotionModelDynamicsBase : private boost::noncopyable

Base class for deriving motion models. Motion models describe the dynamics or kinematics of a rigid body.

Public Types

typedef StateTp state_type
typedef state_type output_type
typedef InputTp input_type
typedef MatrixDescriptor matrix_descriptor_type
typedef matrix_descriptor_type::matrix_type matrix_type
typedef matrix_descriptor_type::vector_type vector_type

Public Functions

virtual ~MotionModelDynamicsBase() = default

Destructor.

virtual state_type &evaluate(const input_type &input) = 0

Updates and returns the value of the state given the input.

inline const state_type &get_state() const

Read access to the state.

inline state_type &get_state()

Read/write access to the state.

inline std::vector<std::string_view> get_state_variables_names() const

get_state_variables_names. Returns the name of the variables in the state

inline matrix_type &get_matrix(const std::string &name)
inline const matrix_type &get_matrix(const std::string &name) const
inline void set_matrix(const std::string &name, const matrix_type &mat)
inline vector_type &get_vector(const std::string &name)
inline const vector_type &get_vector(const std::string &name) const
inline void set_vector(const std::string &name, const vector_type &vec)
inline void set_matrix_update_flag(bool f)

set the matrix update flag

inline bool allows_matrix_updates() const

Set the flag for updating or not the matrices describing the model.

inline bool has_matrix(const std::string &name) const

Returns true if the matrix with the given name already exists.

inline real_t get_state_property(const std::string &name) const

Returns the state property with the given name.

inline void set_state_property(const std::string &name, real_t value)

Set the name-th value of the state.

inline void set_state_name_value(uint_t i, const std::string &name, real_t val)

Set the state names.

inline void set_state_name_value(uint_t i, const std::pair<std::string, real_t> &val)

Set the state names.

inline void set_time_step(real_t dt)

Set the time step.

inline real_t get_time_step() const

get_time_step Returns the sampling time the dynamics model is using

inline real_t get_tolerance() const

get_tolerance Returns the general tolerance used in the calculations

inline void set_tolerance(real_t tol)

set_tolerance Set the general tolerance used in the calculations. Default is KernelConsts::tolerance()

Public Static Attributes

static const uint_t state_dimension = StateTp::dimension

The dimension of the state.

Protected Functions

explicit MotionModelDynamicsBase(bool update_description_matrices_on_evaluate = true)

Constructor.

MotionModelDynamicsBase(const state_type &init_state, bool update_description_matrices_on_evaluate = true)

Constructor.

Protected Attributes

state_type state_

The object describing the state of the object of which its dynamics are described/modeled by this MotionModel.

matrix_descriptor_type matrix_description_

matrix descriptor

bool update_description_matrices_on_evaluate_

flag indicating the update of the matrices the model is using to describe itself

real_t dt_

The time step the integrator uses.

real_t tol_

tolerance

class MountainCar : public rlenvscpp::envs::gymnasium::GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateDiscreteActionEnv<3, 2, 0, real_t>>
#include <mountain_car_env.h>

The MountainCar class.

Public Types

typedef GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateDiscreteActionEnv<3, 2, 0, real_t>>::base_type base_type

Base class type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

Public Functions

MountainCar(const RESTApiServerWrapper &api_server)

MountainCar. Constructor. Creates an environment.

Parameters:
  • version – The version of the environment

  • gym_namespace – The boost::python open-ai gym namespace

  • do_create – If true it calls make

MountainCar(const RESTApiServerWrapper &api_server, const uint_t cidx)

Constructor. Protected so that applications cannot explicitly instantiate copies.

MountainCar(const MountainCar &other)

copy ctor

~MountainCar() = default

~MountainCar. Destructor.

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any>&) final override

make. Build the environment

virtual time_step_type step(const action_type &action) final override

step

MountainCar make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

Public Static Attributes

static const std::string name = "MountainCar"

name

static const std::string URI = "/gymnasium/mountain-car-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

Handle the reset response from the environment server.

template<class B>
struct negation : public std::integral_constant<bool, !B::value>
struct nonesuch

Public Functions

nonesuch() = delete
~nonesuch() = delete
nonesuch(nonesuch const&) = delete
nonesuch(nonesuch const&&) = delete
void operator=(nonesuch const&) = delete
void operator=(nonesuch&&) = delete
template<typename RealType = real_t>
class NormalDist
#include <normal_dist.h>

Wrapper to std::normal_distribution to facilitate sampling multiple values, sampling with a given seed and computing the PDF value at a specific point.

Public Types

typedef RealType result_type

Public Functions

NormalDist()

Constructor.

explicit NormalDist(result_type mu, result_type std = 1.0)

Constructor.

result_type pdf(result_type x) const

compute the value of the PDF at the given point

result_type sample() const

Sample from the distribution.

result_type sample(uint_t seed) const

Sample from the distribution.

std::vector<result_type> sample_many(uint_t size) const

sample from the distribution

std::vector<result_type> sample_many(uint_t size, uint_t seed) const

sample from the distribution

inline result_type mean() const

The mean value of the distribution.

inline result_type std() const

The STD of the distribution.

Private Members

mutable std::normal_distribution<RealType> dist_

The underlying distribution. Mutable as the API exposes const methods and the compiler complains.

struct not_equal

Public Functions

inline bool operator()(board_position a, board_position b) const
struct Null
#include <rlenvs_types_v2.h>

Null placeholder.

template<typename T>
struct optional

Public Functions

inline BETTER_ENUMS_CONSTEXPR_ optional()
inline BETTER_ENUMS_CONSTEXPR_ optional(T v)
inline BETTER_ENUMS_CONSTEXPR_ const T & operator* () const
inline BETTER_ENUMS_CONSTEXPR_ const T * operator-> () const
inline BETTER_ENUMS_CONSTEXPR_ operator bool() const
inline BETTER_ENUMS_CONSTEXPR_ const T & value () const

Private Members

bool _valid
T _value
template<class Key, class T, class IgnoredLess = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T>>>
struct ordered_map : public std::vector<std::pair<const Key, T>, std::allocator<std::pair<const Key, T>>>
#include <json.hpp>

a minimal map-like container that preserves insertion order

ordered_map: a minimal map-like container that preserves insertion order for use within nlohmann::basic_json<ordered_map>

Public Types

using key_type = Key
using mapped_type = T
using Container = std::vector<std::pair<const Key, T>, Allocator>
using iterator = typename Container::iterator
using const_iterator = typename Container::const_iterator
using size_type = typename Container::size_type
using value_type = typename Container::value_type
using key_compare = std::equal_to<Key>
template<typename InputIt>
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category, std::input_iterator_tag>::value>::type

Public Functions

inline ordered_map() noexcept(noexcept(Container()))
inline explicit ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
template<class It>
inline ordered_map(It first, It last, const Allocator &alloc = Allocator())
inline ordered_map(std::initializer_list<value_type> init, const Allocator &alloc = Allocator())
inline std::pair<iterator, bool> emplace(const key_type &key, T &&t)
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline std::pair<iterator, bool> emplace(KeyType &&key, T &&t)
inline T &operator[](const key_type &key)
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline T &operator[](KeyType &&key)
inline const T &operator[](const key_type &key) const
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline const T &operator[](KeyType &&key) const
inline T &at(const key_type &key)
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline T &at(KeyType &&key)
inline const T &at(const key_type &key) const
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline const T &at(KeyType &&key) const
inline size_type erase(const key_type &key)
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline size_type erase(KeyType &&key)
inline iterator erase(iterator pos)
inline iterator erase(iterator first, iterator last)
inline size_type count(const key_type &key) const
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline size_type count(KeyType &&key) const
inline iterator find(const key_type &key)
template<class KeyType, detail::enable_if_t<detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0>
inline iterator find(KeyType &&key)
inline const_iterator find(const key_type &key) const
inline std::pair<iterator, bool> insert(value_type &&value)
inline std::pair<iterator, bool> insert(const value_type &value)
template<typename InputIt, typename = require_input_iter<InputIt>>
inline void insert(InputIt first, InputIt last)

Private Members

JSON_NO_UNIQUE_ADDRESS key_compare m_compare   = key_compare()
class other_error : public detail::exception
#include <json.hpp>

exception indicating other library errors

Public Static Functions

template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
static inline other_error create(int id_, const std::string &what_arg, BasicJsonContext context)

Private Functions

inline other_error(int id_, const char *what_arg)
class out_of_range : public detail::exception
#include <json.hpp>

exception indicating access out of the defined range

Public Static Functions

template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
static inline out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)

Private Functions

inline out_of_range(int id_, const char *what_arg)
template<typename CharType, typename StringType = std::basic_string<CharType>>
class output_adapter

Public Functions

template<typename AllocatorType = std::allocator<CharType>>
inline output_adapter(std::vector<CharType, AllocatorType> &vec)
inline output_adapter(std::basic_ostream<CharType> &s)
inline output_adapter(StringType &s)
inline operator output_adapter_t<CharType>()

Private Members

output_adapter_t<CharType> oa = nullptr
template<typename CharType>
struct output_adapter_protocol
#include <json.hpp>

abstract output adapter interface

Subclassed by detail::output_stream_adapter< CharType >, detail::output_string_adapter< CharType, StringType >, detail::output_vector_adapter< CharType, AllocatorType >

Public Functions

virtual void write_character(CharType c) = 0
virtual void write_characters(const CharType *s, std::size_t length) = 0
virtual ~output_adapter_protocol() = default
output_adapter_protocol() = default
output_adapter_protocol(const output_adapter_protocol&) = default
output_adapter_protocol(output_adapter_protocol&&) noexcept = default
output_adapter_protocol &operator=(const output_adapter_protocol&) = default
output_adapter_protocol &operator=(output_adapter_protocol&&) noexcept = default
template<typename CharType>
class output_stream_adapter : public detail::output_adapter_protocol<CharType>
#include <json.hpp>

output adapter for output streams

Public Functions

inline explicit output_stream_adapter(std::basic_ostream<CharType> &s) noexcept
inline virtual void write_character(CharType c) override
inline virtual void write_characters(const CharType *s, std::size_t length) override

Private Members

std::basic_ostream<CharType> &stream
template<typename CharType, typename StringType = std::basic_string<CharType>>
class output_string_adapter : public detail::output_adapter_protocol<CharType>
#include <json.hpp>

output adapter for basic_string

Public Functions

inline explicit output_string_adapter(StringType &s) noexcept
inline virtual void write_character(CharType c) override
inline virtual void write_characters(const CharType *s, std::size_t length) override

Private Members

StringType &str
template<typename CharType, typename AllocatorType = std::allocator<CharType>>
class output_vector_adapter : public detail::output_adapter_protocol<CharType>
#include <json.hpp>

output adapter for byte vectors

Public Functions

inline explicit output_vector_adapter(std::vector<CharType, AllocatorType> &vec) noexcept
inline virtual void write_character(CharType c) override
inline virtual void write_characters(const CharType *s, std::size_t length) override

Private Members

std::vector<CharType, AllocatorType> &v
class parse_error : public detail::exception
#include <json.hpp>

exception indicating a parse error

Public Members

const std::size_t byte

byte index of the parse error

The byte index of the last read character in the input file.

Note

For an input with n bytes, 1 is the index of the first character and n+1 is the index of the terminating null byte or the end of file. This also holds true when reading a byte vector (CBOR or MessagePack).

Public Static Functions

template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
static inline parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)

create a parse error exception

Parameters:
  • id_[in] the id of the exception

  • pos[in] the position where the error occurred (or with chars_read_total=0 if the position cannot be determined)

  • what_arg[in] the explanatory string

Returns:

parse_error object

template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
static inline parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)

Private Functions

inline parse_error(int id_, std::size_t byte_, const char *what_arg)

Private Static Functions

static inline std::string position_string(const position_t &pos)
template<typename BasicJsonType, typename InputAdapterType>
class parser
#include <json.hpp>

syntax analysis

This class implements a recursive descent parser.

Public Functions

inline explicit parser(InputAdapterType &&adapter, const parser_callback_t<BasicJsonType> cb = nullptr, const bool allow_exceptions_ = true, const bool skip_comments = false)

a parser reading from an input adapter

inline void parse(const bool strict, BasicJsonType &result)

public parser interface

Parameters:
  • strict[in] whether to expect the last token to be EOF

  • result[inout] parsed JSON value

Throws:
  • parse_error.101 – in case of an unexpected token

  • parse_error.102 – if to_unicode fails or surrogate error

  • parse_error.103 – if to_unicode fails

inline bool accept(const bool strict = true)

public accept interface

Parameters:

strict[in] whether to expect the last token to be EOF

Returns:

whether the input is a proper JSON text

template<typename SAX>
inline bool sax_parse(SAX *sax, const bool strict = true)

Private Types

using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using number_float_t = typename BasicJsonType::number_float_t
using string_t = typename BasicJsonType::string_t
using lexer_t = lexer<BasicJsonType, InputAdapterType>
using token_type = typename lexer_t::token_type

Private Functions

template<typename SAX>
inline bool sax_parse_internal(SAX *sax)
inline token_type get_token()

get next token from lexer

inline std::string exception_message(const token_type expected, const std::string &context)

Private Members

const parser_callback_t<BasicJsonType> callback = nullptr

callback function

token_type last_token = token_type::uninitialized

the type of the last read token

lexer_t m_lexer

the lexer

const bool allow_exceptions = true

whether to throw exceptions in case of errors

class Pendulum : public rlenvscpp::envs::gymnasium::GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateContinuousScalarBoundedActionEnv<3, 1, RealRange<-2.0, 2.0>, 0, real_t>>
#include <pendulum_env.h>

The Pendulum class. Interface for Pendulum environment.

Public Types

typedef GymnasiumEnvBase<TimeStep<std::vector<real_t>>, ContinuousVectorStateContinuousScalarBoundedActionEnv<3, 1, RealRange<-2.0, 2.0>, 0, real_t>>::base_type base_type

Base class type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

Public Functions

Pendulum(const RESTApiServerWrapper &api_server)

Pendulum. Constructor.

Pendulum(const RESTApiServerWrapper &api_server, const uint_t cidx)

Constructor.

Pendulum(const Pendulum &other)

copy ctor

~Pendulum() = default

~Pendulum. Destructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any>&) final override

make. Build the environment

virtual time_step_type step(const action_type &action) final override

step. Step in the environment following the given action

Pendulum make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

Public Static Attributes

static const std::string name = "Pendulum"

name

static const std::string URI = "/gymnasium/pendulum-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

Handle the reset response from the environment server.

struct position_t
#include <json.hpp>

struct to capture the start position of the current token

Public Functions

inline constexpr operator size_t() const

conversion to size_t to preserve SAX interface

Public Members

std::size_t chars_read_total = 0

the total number of characters read

std::size_t chars_read_current_line = 0

the number of characters read in the current line

std::size_t lines_read = 0

the number of lines read

class primitive_iterator_t

Public Functions

inline constexpr difference_type get_value() const noexcept
inline void set_begin() noexcept

set iterator to a defined beginning

inline void set_end() noexcept

set iterator to a defined past the end

inline constexpr bool is_begin() const noexcept

return whether the iterator can be dereferenced

inline constexpr bool is_end() const noexcept

return whether the iterator is at end

inline primitive_iterator_t operator+(difference_type n) noexcept
inline primitive_iterator_t &operator++() noexcept
inline primitive_iterator_t operator++(int) & noexcept
inline primitive_iterator_t &operator--() noexcept
inline primitive_iterator_t operator--(int) & noexcept
inline primitive_iterator_t &operator+=(difference_type n) noexcept
inline primitive_iterator_t &operator-=(difference_type n) noexcept

Private Types

using difference_type = std::ptrdiff_t

Private Members

JSON_PRIVATE_UNLESS_TESTED __pad0__

Private Static Attributes

static constexpr difference_type begin_value = 0
static constexpr difference_type end_value = begin_value + 1

Friends

inline friend constexpr friend bool operator== (primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
inline friend constexpr friend bool operator< (primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
inline friend constexpr friend difference_type operator- (primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
template<unsigned N>
struct priority_tag
template<>
struct priority_tag<0>
class QuadcopterSimEnv : public rlenvscpp::envs::EnvBase<TimeStep<std::vector<real_t>>, std::vector<real_t>>

Public Types

typedef EnvBase<TimeStep<std::vector<real_t>>, std::vector<real_t>>::time_step_type time_step_type
typedef EnvBase<TimeStep<std::vector<real_t>>, std::vector<real_t>>::action_type action_type

Public Functions

inline QuadcopterSimEnv(const std::string &url, const std::string &name)

constructor

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any> &options) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type step(const action_type &action) final override

step

Parameters:

action

Returns:

virtual void close() final override

close the environment

virtual time_step_type reset(uint_t seed, const std::unordered_map<std::string, std::any> &options) final override

Reset the environment.

bool is_alive() const noexcept

Query the environment server is the environment has been created.

Private Functions

time_step_type create_time_step_from_response_(const http::Response &response) const

build the time step from the server response

Private Members

time_step_type current_state_
class Quadrotor

Private Members

real_t mass_

The mass of the quadrotor.

real_t l_

the arm length

class QuadrotorDynamics : public rlenvscpp::dynamics::MotionModelDynamicsBase<SysState<12>, DynamicsMatrixDescriptor, RealVec>

The QuadrotorDynamics class. Implements quadrotor dynamics The implementation of this class follows the System Modeling section at https://wilselby.com/research/arducopter/modeling/ and https://scholarsarchive.byu.edu/cgi/viewcontent.cgi?article=2324&context=facpub The quadrotor is assumed to have four rotors Each rotor consists of a brushless DC motor and rotor with a fixed pitch. It is assumed that the quadrotor can move in 6 degrees of freedom; 3-translational and 3-rotational, The motion of the quadrotor is controlled via 4 inputs namely the speeds of the 4 motors. The quadrotor model that this class implements assumes the following:

  • The quadrotor structure is rigid and symmetrical with a center of mass aligned with the center of the body frame of the vehicle.

  • The thrust and drag of each motor is proportional to the square of the motor velocity.

  • The propellers are considered to be rigid and therefore blade flapping is negligible (deformation of propeller blades due to high velocities and flexible material).

  • The Earth is flat and non-rotating (difference of gravity by altitude or the spin of the earth is negligible)

  • Surrounding fluid velocities (wind) are negligible.

  • Ground effect is negligible

The class integrates the translational and rotational dynamics equations on the body frame

Public Types

typedef MotionModelDynamicsBase<SysState<12>, DynamicsMatrixDescriptor, RealVec> base_type
typedef base_type::state_type state_type

The type of the state handled by this dynamics object.

typedef base_type::input_type input_type

input_t The type of the input for solving the dynamics

typedef base_type::matrix_type matrix_type

matrix_t Matrix type that describes the dynamics

typedef base_type::vector_type vector_type

vector_t

Public Functions

QuadrotorDynamics(QuadrotorDynamicsConfig config, SysState<12> &state)

QuadrotorDynamics Constructor. Specify the configuration parameters of the simulated quadrotor. It is assumed that the mass of the quadrotor remains fixed and the system state to be tracked.

virtual state_type &evaluate(const input_type &input) override

Evaluate the new state using the given input it also updates the various matrices if needed.

void integrate(const RealVec &motor_w)

Integrate the new state. It also uses error terms.

void translational_dynamics(const RealVec &motor_w)

Implements the translational dynamics. It accepts the motors angular velocities. Notice that this model will squared and input velocities.

void rotational_dynamics(const RealVec &motor_w)

Implements the translational dynamics. It accepts the motors angular velocities. Notice that this model will squared and input velocities.

inline RealColVec3d get_position() const

Returns the current position NED frame.

inline RealColVec3d get_velocity() const

Returns the current linear velocity (body frame)

inline RealColVec3d get_angular_velocity() const

Returns the current angular velocity (body frame)

inline RealColVec3d get_euler_angles() const

Returns the Euler angles (0: phi, 1: theta, 2:psi)

Private Functions

void update_position_()

Update the position

void update_rotation_matrix_()

Update the rotation matrix.

void update_euler_angles_()
inline RealColVec3d get_velocity_from_state_() const
inline RealColVec3d get_angular_velocity_from_state_() const
inline RealColVec3d get_position_from_state_() const
inline RealColVec3d get_euler_angles_from_state_() const

Private Members

QuadrotorDynamicsConfig config_

Configuration of the dynamics integrator.

RealMat3d rotation_mat_

The rotation matrix from body to inertial frames.

RealMat3d euler_mat_

The rotation matrix from body to inertial frames.

RealColVec3d v_dot_

Track the velocity time gradient.

RealColVec3d omega_dot_

Track the angular velocity time gradient.

RealColVec3d euler_dot_

The time derivative of the euler angles.

struct QuadrotorDynamicsConfig

Public Members

bool use_gravity = {true}

flag indicating if gravity is used

bool use_description_matrices = {false}
real_t mass

mass

real_t l

the arm length

real_t k_1

Proportionality constant to scale the morot velocity.

real_t k_2

Proportionality constant to scale the morot velocity used when calculating torques.

real_t dt

The time step to ise.

real_t Jx
real_t Jy
real_t Jz
template<real_t s, real_t e>
struct RealRange
#include <rlenvs_types_v2.h>

A range of double precision floating point values.

Public Types

typedef real_t value_type

Public Static Attributes

static constexpr real_t S = s
static constexpr real_t E = e
static constexpr real_t size = e - s
class Request

Public Functions

inline explicit Request(const std::string &uriString, const InternetProtocol protocol = InternetProtocol::v4)
inline Response send(const std::string &method = "GET", const std::string &body = "", const HeaderFields &headerFields = {}, const std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})
inline Response send(const std::string &method, const std::vector<uint8_t> &body, const HeaderFields &headerFields = {}, const std::chrono::milliseconds timeout = std::chrono::milliseconds{-1})

Private Members

InternetProtocol internetProtocol
Uri uri
class RequestError : public std::logic_error
struct Response

Public Members

Status status
HeaderFields headerFields
std::vector<std::uint8_t> body
class ResponseError : public std::runtime_error
class RESTApiServerWrapper
#include <apiserver.h>

Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.

Public Functions

explicit RESTApiServerWrapper(const std::string &url = "http://0.0.0.0:8001/api", const bool initialize = true)

Constructor.

inline bool is_inisialised() const noexcept

Returns true if the server is initialised.

inline std::string get_url() const noexcept

Returns the remote url.

std::string get_env_url(const std::string &name) const noexcept

Return the url for the environment with the given name.

std::string get_uri(const std::string &name) const noexcept

Returns the URI of the environment with the given name Returns INVALID_STR if the environment is not registered.

void register_new(const std::string &name, const std::string &uri)

Register a new environment. Throws std::logic_error if the environment name already exists.

void register_if_not(const std::string &name, const std::string &uri)

Same as register_new but swallows the thrown exception.

nlohmann::json is_alive(const std::string &env_name, const uint_t cidx) const

Queries the remote server if the environment with the given cidx is alive Throws std::logic_error is the environment is not registered.

nlohmann::json close(const std::string &env_name, const uint_t cidx) const

Close the environment with the given name. Throws std::logic_error is the environment is not registered Throws std::runtime_error if the server response is not 201.

template<typename ActionType>
nlohmann::json step(const std::string &env_name, const uint_t cidx, const ActionType &action) const

Step in the environment with the given name and the given copy index executing action. ActionType has to be JSON serializable Throws std::logic_error is the environment is not registered Throws std::runtime_error if the server response is not 201.

nlohmann::json reset(const std::string &env_name, const uint_t cidx, const uint_t seed, const nlohmann::json &options) const

Reset the the environment with the given name and the given copy index executing action. Throws std::logic_error is the environment is not registered Throws std::runtime_error if the server response is not 202.

nlohmann::json make(const std::string &env_name, const uint_t cidx, const std::string &version, const nlohmann::json &options) const

Make the the environment with the given name and the given copy index executing action. Throws std::logic_error is the environment is not registered Throws std::runtime_error if the server response is not 202.

nlohmann::json dynamics(const std::string &env_name, const uint_t cidx, const uint_t sidx, const uint_t aidx) const

Get the dynamics of the environment. If the environment does not expose such an endpoint it returns 404.

inline nlohmann::json copy(const std::string &env_name, const uint_t cidx, const std::string &version, const nlohmann::json &options) const

Make the cidx copy of the environment.

bool has_gymnasium() const
std::vector<std::string> gymnasium_envs() const

Private Functions

void init_()

Initialzes the available environments.

Private Members

const std::string url_

The source url of the remote server.

bool is_init_ = {false}

Flag indicating if the underlying environments have been initialised.

std::unordered_map<std::string, std::string> envs_

Map that holds the environment names and their respective URI on the remote server.

template<uint_t state_end, uint_t action_end, uint_t state_start = 0, uint_t action_start = 0>
struct ScalarDiscreteEnv

Subclassed by rlenvscpp::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 2, 0, 0 > >

Public Types

typedef ScalarDiscreteSpace<state_start, state_end> state_space

item_t

typedef state_space::space_item_type state_type

the State type

typedef ScalarDiscreteSpace<action_start, action_end> action_space

the action space type

typedef action_space::space_item_type action_type

the Action type

Public Static Functions

static inline action_type sample_action()

sample

Returns:

static inline action_type sample_action(uint_t seed)

sample

Parameters:

seed

Returns:

static inline std::vector<action_type> sample_action(uint_t seed, uint_t size)

Public Static Attributes

static constexpr uint_t STATE_SPACE_SIZE = state_space::size

state space size

static constexpr uint_t ACTION_SPACE_SIZE = action_space::size

action space size

template<uint_t s, uint_t e>
struct ScalarDiscreteSpace
#include <space_type.h>

A scalar discrete space can be used to denote a space that only has a single value at each time. For example consider the FrozenLake environment then both the state and the action spaces are ScalarDiscreteSpace.

Public Types

typedef uint_t space_item_type

item_t

Public Static Functions

static space_item_type sample(bool use_end)

sample

Returns:

static space_item_type sample(uint_t seed, bool use_end)

sample

Parameters:

seed

Returns:

static std::vector<space_item_type> sample(uint_t seed, uint_t size, bool use_end)

sample

Parameters:

seed

Returns:

Public Static Attributes

static constexpr IntegralRange<s, e> limits = IntegralRange<s, e>()

The limits of the space.

static constexpr uint_t size = IntegralRange<s, e>::size

The overall size of the space meaning how many elements can potentially the space have.

template<typename BasicJsonType>
class serializer

Public Functions

inline serializer(output_adapter_t<char> s, const char ichar, error_handler_t error_handler_ = error_handler_t::strict)
Parameters:
  • s[in] output stream to serialize to

  • ichar[in] indentation character to use

  • error_handler_[in] how to react on decoding errors

serializer(const serializer&) = delete
serializer &operator=(const serializer&) = delete
serializer(serializer&&) = delete
serializer &operator=(serializer&&) = delete
~serializer() = default
inline void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent = 0)

internal implementation of the serialization function

This function is called by the public member function dump and organizes the serialization internally. The indentation level is propagated as additional parameter. In case of arrays and objects, the function is called recursively.

  • strings and object keys are escaped using escape_string()

  • integer numbers are converted implicitly via operator<<

  • floating-point numbers are converted to a string using "%g" format

  • binary values are serialized as objects containing the subtype and the byte array

Parameters:
  • val[in] value to serialize

  • pretty_print[in] whether the output shall be pretty-printed

  • ensure_ascii[in] If ensure_ascii is true, all non-ASCII characters in the output are escaped with \uXXXX sequences, and the result consists of ASCII characters only.

  • indent_step[in] the indent level

  • current_indent[in] the current indent level (only used internally)

inline  for (std::size_t i=0;i< s.size();++i)
inline  if (JSON_HEDLEY_LIKELY(state==UTF8_ACCEPT))

Public Members

JSON_PRIVATE_UNLESS_TESTED __pad0__
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii  {std::uint32_t codepoint{}
std::uint8_t state = UTF8_ACCEPT
std::size_t bytes = 0
std::size_t bytes_after_last_accept = 0
std::size_t undumped_chars = 0
else
std::array<char, 64> number_buffer = {{}}

a (hopefully) large enough character buffer

const std::lconv *loc = nullptr

the locale

const char thousands_sep = '\0'

the locale’s thousand separator character

const char decimal_point = '\0'

the locale’s decimal point character

std::array<char, 512> string_buffer = {{}}

string buffer

const char indent_char

the indentation character

string_t indent_string

the indentation string

const error_handler_t error_handler

error_handler how to react on decoding errors

Private Types

using string_t = typename BasicJsonType::string_t
using number_float_t = typename BasicJsonType::number_float_t
using number_integer_t = typename BasicJsonType::number_integer_t
using number_unsigned_t = typename BasicJsonType::number_unsigned_t
using binary_char_t = typename BasicJsonType::binary_t::value_type

Private Static Attributes

static constexpr std::uint8_t UTF8_ACCEPT = 0
static constexpr std::uint8_t UTF8_REJECT = 1
class Socket

Public Types

using Type = int

Public Functions

inline explicit Socket(const InternetProtocol internetProtocol)
inline ~Socket()
inline Socket(Socket &&other) noexcept
inline Socket &operator=(Socket &&other) noexcept
inline void connect(const struct sockaddr *address, const socklen_t addressSize, const std::int64_t timeout)
inline std::size_t send(const void *buffer, const std::size_t length, const std::int64_t timeout)
inline std::size_t recv(void *buffer, const std::size_t length, const std::int64_t timeout)

Public Static Attributes

static constexpr Type invalid = -1

Private Types

enum class SelectType

Values:

enumerator read
enumerator write

Private Functions

inline void select(const SelectType type, const std::int64_t timeout)
inline void close() noexcept

Private Members

Type endpoint = invalid

Private Static Attributes

static constexpr int noSignal = 0
class Socket

Public Types

using Type = int

Public Functions

inline explicit Socket(const InternetProtocol internetProtocol)
inline ~Socket()
inline Socket(Socket &&other) noexcept
inline Socket &operator=(Socket &&other) noexcept
inline void connect(const struct sockaddr *address, const socklen_t addressSize, const std::int64_t timeout)
inline std::size_t send(const void *buffer, const std::size_t length, const std::int64_t timeout)
inline std::size_t recv(void *buffer, const std::size_t length, const std::int64_t timeout)

Public Static Attributes

static constexpr Type invalid = -1

Private Types

enum class SelectType

Values:

enumerator read
enumerator write

Private Functions

inline void select(const SelectType type, const std::int64_t timeout)
inline void close() noexcept

Private Members

Type endpoint = invalid

Private Static Attributes

static constexpr int noSignal = 0
class span_input_adapter

Public Functions

template<typename CharT, typename std::enable_if<std::is_pointer<CharT>::value && std::is_integral<typename std::remove_pointer<CharT>::type>::value && sizeof(typename std::remove_pointer<CharT>::type) == 1, int>::type = 0>
inline span_input_adapter(CharT b, std::size_t l)
template<class IteratorType, typename std::enable_if<std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value, int>::type = 0>
inline span_input_adapter(IteratorType first, IteratorType last)
inline contiguous_bytes_input_adapter &&get()
template<typename EnvType, typename StateTp>
class StateAggregationEnvBase

The TiledEnviromentBase class. Base class to derive enviroments that discretize the continues state into a discrete number of bins.

template<typename T>
struct static_const

Public Static Attributes

static constexpr JSON_INLINE_VARIABLE T value   = {}
struct Status

Public Types

enum Code

Values:

enumerator Continue
enumerator SwitchingProtocol
enumerator Processing
enumerator EarlyHints
enumerator Ok
enumerator Created
enumerator Accepted
enumerator NonAuthoritativeInformation
enumerator NoContent
enumerator ResetContent
enumerator PartialContent
enumerator MultiStatus
enumerator AlreadyReported
enumerator ImUsed
enumerator MultipleChoice
enumerator MovedPermanently
enumerator Found
enumerator SeeOther
enumerator NotModified
enumerator UseProxy
enumerator TemporaryRedirect
enumerator PermanentRedirect
enumerator BadRequest
enumerator Unauthorized
enumerator PaymentRequired
enumerator Forbidden
enumerator NotFound
enumerator MethodNotAllowed
enumerator NotAcceptable
enumerator ProxyAuthenticationRequired
enumerator RequestTimeout
enumerator Conflict
enumerator Gone
enumerator LengthRequired
enumerator PreconditionFailed
enumerator PayloadTooLarge
enumerator UriTooLong
enumerator UnsupportedMediaType
enumerator RangeNotSatisfiable
enumerator ExpectationFailed
enumerator MisdirectedRequest
enumerator UnprocessableEntity
enumerator Locked
enumerator FailedDependency
enumerator TooEarly
enumerator UpgradeRequired
enumerator PreconditionRequired
enumerator TooManyRequests
enumerator RequestHeaderFieldsTooLarge
enumerator UnavailableForLegalReasons
enumerator InternalServerError
enumerator NotImplemented
enumerator BadGateway
enumerator ServiceUnavailable
enumerator GatewayTimeout
enumerator HttpVersionNotSupported
enumerator VariantAlsoNegotiates
enumerator InsufficientStorage
enumerator LoopDetected
enumerator NotExtended
enumerator NetworkAuthenticationRequired

Public Members

HttpVersion httpVersion
std::uint16_t code
std::string reason
template<typename T>
struct string_t_helper

Public Types

using type = T
template<>
struct string_t_helper<NLOHMANN_BASIC_JSON_TPL>

Public Types

using type = StringType
struct synchronized_env_mixin

class synchronized_env_mixin

Subclassed by rlenvscpp::envs::EnvBase< TimeStep< detail::board_state_type >, detail::GridWorldEnv< side_size_ > >, rlenvscpp::envs::EnvBase< TimeStep< std::vector< uint_t > >, DiscreteVectorStateDiscreteActionEnv< 53, 0, 4, uint_t > >, rlenvscpp::envs::EnvBase< TimeStep< std::vector< real_t > >, std::vector< real_t > >, rlenvscpp::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 2, 0, 0 > >, rlenvscpp::envs::EnvBase< TimeStepType, SpaceType >

Public Functions

inline virtual void sync(const std::unordered_map<std::string, std::any>&)

Synchronize the environment.

template<int dim>
class SysState
#include <system_state.h>

SysState utility class describing the state of a system.

Public Types

typedef std::array<std::pair<std::string, real_t>, dim> value_type

The type of the stored values.

Public Functions

SysState()

Constructor. Initialize the state with no names.

SysState(std::array<std::pair<std::string, real_t>, dim> &&values)

Constructor. Initialize the state with the given names and values.

SysState(std::array<std::string, dim> &&names, real_t val)

Constructor. Initialize the state with the given names all variables will be initialized with val.

SysState(const SysState<dim> &other)

Copy constructor.

template<int other_dim>
SysState(const SysState<other_dim> &other)

Copy constructor.

SysState &operator=(const SysState<dim> &other)

Copy assignement constructor.

SysState(SysState &&other)

Move copy constructor.

SysState &operator=(SysState &&other)

Move copy constructor.

SysState &operator+=(const DynVec<real_t> &vec)

Add to this state the entries of the give vector.

SysState &operator-=(const DynVec<real_t> &vec)

Subtract from this state the entries of the give vector.

SysState &operator*=(real_t val)

Scale this state by the given factor.

real_t get(const std::string &name) const

Returns the value for the variable name.

DynVec<real_t> as_vector() const

Returns the entries of this state as a DynVec.

void set(const std::string &name, real_t val)

Set the value for the variable name.

void set(uint_t i, const std::pair<std::string, real_t> &value)

Set the name and value of the i-th variable.

void add(const DynVec<real_t> &container)

Set the values of state variables container must be of size dim.

void add(const std::vector<real_t> &container)

Set the values of state variables container must be of size dim.

inline uint_t size() const

Returns the size of the system.

const std::array<real_t, dim> get_values() const

Returns a copy of the state values.

const std::vector<std::string_view> get_names() const

Returns a copy of the state names.

real_t &operator[](uint_t)

Access operator.

const real_t &operator[](uint_t) const

Access operator.

inline real_t &operator[](const std::string &name)

Access operator.

inline const real_t &operator[](const std::string &name) const

Access operator.

real_t &operator()(const std::string &name)

Access operator.

const real_t &operator()(const std::string &name) const

Access operator.

inline real_t &operator()(const std::string_view name)

Access operator.

inline const real_t &operator()(const std::string_view name) const

Access operator.

void clear()

clear the state

std::ostream &print(std::ostream &out) const

Print the state at the given stream.

const std::string as_string() const

Return the state as string.

void scale(real_t val)

Scale the values of the state.

template<typename Container>
void set(const Container &container)

Set the values.

Public Static Functions

template<int dim1, int dim2>
static void extract(const SysState<dim1> &state, SysState<dim2> &other)

Extract a state of different dimension.

Public Static Attributes

static const int dimension = dim

The dimension of the state.

Private Members

std::array<std::pair<std::string, real_t>, dim> values_

Returns a view of the values in [start, end)

TODO: Add this in the future

values_. Array holding the values of the state

class Taxi : public rlenvscpp::envs::gymnasium::ToyTextEnvBase<TimeStep<uint_t>, 500, 6>
#include <taxi_env.h>

The Taxi class.

Public Types

typedef ToyTextEnvBase<TimeStep<uint_t>, 500, 6>::base_type base_type

The base type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the action to be undertaken in the environment.

Public Functions

Taxi(const RESTApiServerWrapper &api_server)

Taxi.

Taxi(const RESTApiServerWrapper &api_server, const uint_t cidx)

Constructor.

Taxi(const Taxi &other)

copy constructor

~Taxi() = default

~FrozenLake. Destructor.

virtual void make(const std::string &version, const std::unordered_map<std::string, std::any>&) final override

make. Builds the environment. Optionally we can choose if the environment will be slippery

virtual time_step_type step(const action_type &action) final override

step

Taxi make_copy(uint_t cidx) const

Create a new copy of the environment with the given copy index.

Public Static Attributes

static const std::string name = "Taxi"

name

static const std::string URI = "/gymnasium/taxi-env"

The URI for accessing the environment.

Protected Functions

virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const final override

build the dynamics from response

Handle the reset response from the environment server

class TensorboardServer : private boost::noncopyable

class TensorboardServer

Public Functions

TensorboardServer(const std::string &api_url)

Constructor.

void init(const std::string &log_dir)

Set the log_dir for this instance.

void close()

Close the TensorboardServer.

void add_scalar(const std::string &tag, real_t value, uint_t step_idx = rlenvscpp::consts::INVALID_ID) const

Add scalar.

void add_scalars(const std::string &main_tag, const std::unordered_map<std::string, real_t> &values, uint_t step_idx = rlenvscpp::consts::INVALID_ID) const

Add scalar.

void add_text(const std::string &tag, const std::string &text, uint_t step_idx = rlenvscpp::consts::INVALID_ID) const

Add scalar.

inline std::string_view get_log_dir_path() const noexcept

Return the directory for logging.

inline std::string_view get_server_address() const noexcept

Return the server address.

Private Members

std::string api_url_
std::string log_dir_
const std::string api_str_
template<typename StateTp>
class TimeStep
#include <time_step.h>

Forward declaration.

The TimeStep class.

Public Types

typedef StateTp state_type

state_ Type of the state

Public Functions

TimeStep()

TimeStep.

TimeStep(TimeStepTp type, real_t reward, const state_type &obs)

TimeStep. Constructor.

TimeStep(TimeStepTp type, real_t reward, const state_type &obs, real_t discount_factor)

TimeStep. Constructor.

TimeStep(TimeStepTp type, real_t reward, const state_type &obs, real_t discount_factor, std::unordered_map<std::string, std::any> &&extra)

TimeStep. Constructor.

TimeStep(const TimeStep &other)

TimeStep.

Parameters:

other

TimeStep &operator=(const TimeStep &other)

Assignment operator.

TimeStep(TimeStep &&other) noexcept

TimeStep.

Parameters:

other

TimeStep &operator=(TimeStep &&other) noexcept

operator =

Parameters:

other

Returns:

inline bool first() const noexcept

first

Returns:

inline bool mid() const noexcept

mid

Returns:

inline bool last() const noexcept

last

Returns:

inline TimeStepTp type() const noexcept

type

Returns:

inline state_type observation() const

observation

Returns:

inline real_t reward() const noexcept

reward

Returns:

inline real_t discount() const noexcept

discount. Returns the discount factor

inline bool done() const noexcept

done

Returns:

void clear() noexcept

clear

template<typename T>
const T &get_extra(std::string name) const

get_extra

inline const std::unordered_map<std::string, std::any> &info() const noexcept

info

Returns:

inline std::unordered_map<std::string, std::any> &info() noexcept

info

Returns:

Private Members

TimeStepTp type_

type_

real_t reward_

reward_

state_type obs_

obs_

real_t discount_

discount_. The discount_factor

std::unordered_map<std::string, std::any> extra_

extra_

struct TimeStepEnumUtils
#include <time_step_type.h>

Utilities for TimeStepTp.

Public Static Functions

static TimeStepTp time_step_type_from_int(int aidx)
static TimeStepTp time_step_type_from_int(uint_t aidx)
static std::string to_string(TimeStepTp type)
static std::vector<TimeStepTp> time_step_type_from_int(const std::vector<uint_t> &types)
struct to_json_fn

Public Functions

template<typename BasicJsonType, typename T>
inline auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward<T>(val)))) -> decltype(to_json(j, std::forward<T>(val)), void())
template<typename TimeStepType, uint_t state_end, uint_t action_end>
class ToyTextEnvBase : public rlenvscpp::envs::gymnasium::GymnasiumEnvBase<TimeStepType, ScalarDiscreteEnv<state_end, action_end, 0, 0>>
#include <toy_text_base.h>

ToyTextEnvBase class. Base class for toy environments from Gymnasium. These environments have a discrete action and state spaces.

Public Types

typedef GymnasiumEnvBase<TimeStepType, ScalarDiscreteEnv<state_end, action_end, 0, 0>>::base_type base_type

The base_type.

typedef base_type::time_step_type time_step_type

The time step type we return every time a step in the environment is performed.

typedef base_type::state_space_type state_space_type

The type describing the state space for the environment.

typedef base_type::action_space_type action_space_type

The type of the action space for the environment.

typedef base_type::action_type action_type

The type of the action to be undertaken in the environment.

typedef base_type::state_type state_type

The type of the state.

typedef std::vector<std::tuple<real_t, uint_t, real_t, bool>> dynamics_t

dynamics_t

Public Functions

virtual ~ToyTextEnvBase() = default

~FrozenLake. Destructor.

dynamics_t p(uint_t sidx, uint_t aidx) const

P.

Parameters:
  • sidx

  • aidx

inline uint_t n_actions() const noexcept

n_actions. Returns the number of actions

inline uint_t n_states() const noexcept

Number of states.

Protected Functions

ToyTextEnvBase(const RESTApiServerWrapper &api_server, const uint_t cidx, const std::string &name)

Constructor.

ToyTextEnvBase(const ToyTextEnvBase &other)

Copy constructor.

virtual dynamics_t build_dynamics_from_response_(const nlohmann::json &response) const

build the dynamics from response

template<std::size_t N, typename IteratorType>
class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType>>

Public Types

using type = decltype(get<N>(std::declval<::nlohmann::detail::iteration_proxy_value<IteratorType>>()))
template<typename IteratorType>
class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>> : public std::integral_constant<std::size_t, 2>
struct two

Public Members

char x[2]
class type_error : public detail::exception
#include <json.hpp>

exception indicating executing a member function with a wrong type

Public Static Functions

template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value, int> = 0>
static inline type_error create(int id_, const std::string &what_arg, BasicJsonContext context)

Private Functions

inline type_error(int id_, const char *what_arg)
struct Uri

Public Members

std::string scheme
std::string user
std::string password
std::string host
std::string port
std::string path
std::string query
std::string fragment
template<typename OfType, typename T, bool NeverOutOfRange = never_out_of_range<OfType, T>::value, typename = detail::enable_if_t<all_integral<OfType, T>::value>>
struct value_in_range_of_impl1
template<typename OfType, typename T>
struct value_in_range_of_impl1<OfType, T, false>

Public Static Functions

static inline constexpr bool test(T val)
template<typename OfType, typename T>
struct value_in_range_of_impl1<OfType, T, true>

Public Static Functions

static inline constexpr bool test(T)
template<typename OfType, typename T, bool OfTypeSigned = std::is_signed<OfType>::value, bool TSigned = std::is_signed<T>::value>
struct value_in_range_of_impl2
template<typename OfType, typename T>
struct value_in_range_of_impl2<OfType, T, false, false>

Public Static Functions

static inline constexpr bool test(T val)
template<typename OfType, typename T>
struct value_in_range_of_impl2<OfType, T, false, true>

Public Static Functions

static inline constexpr bool test(T val)
template<typename OfType, typename T>
struct value_in_range_of_impl2<OfType, T, true, false>

Public Static Functions

static inline constexpr bool test(T val)
template<typename OfType, typename T>
struct value_in_range_of_impl2<OfType, T, true, true>

Public Static Functions

static inline constexpr bool test(T val)
template<typename StateType>
class VectorTimeStep
#include <vector_time_step.h>

Forward declaration.

VectorTimeSetp class.

Public Types

typedef StateType state_type

state_ Type of the state

Public Functions

VectorTimeStep() = default

Default construcotr.

VectorTimeStep(const std::vector<TimeStepTp> &types, const std::vector<real_t> &rewards, const std::vector<state_type> &obs)

VectorTimeStep. Constructor.

VectorTimeStep(const std::vector<TimeStepTp> &types, const std::vector<real_t> &rewards, const std::vector<state_type> &obs, const std::vector<real_t> &discount_factors)

VectorTimeStep. Constructor.

VectorTimeStep(const std::vector<TimeStepTp> &types, const std::vector<real_t> &rewards, const std::vector<state_type> &obs, const std::vector<real_t> &discount_factors, std::unordered_map<std::string, std::any> &&extra)
VectorTimeStep(const VectorTimeStep &other)

TimeStep.

Parameters:

other

VectorTimeStep &operator=(const VectorTimeStep &other)

Assignment operator.

VectorTimeStep(VectorTimeStep &&other) noexcept

TimeStep.

Parameters:

other

VectorTimeStep &operator=(VectorTimeStep &&other) noexcept

operator =

Parameters:

other

Returns:

inline const std::vector<TimeStepTp> &types() const noexcept

type

Returns:

inline const std::vector<state_type> &observations() const

observation

Returns:

inline const std::vector<real_t> &rewards() const noexcept

reward

Returns:

real_t reward() const noexcept

Returns the sum of the rewards received.

bool done() const noexcept

Returns true if any time step is LAST.

inline const std::vector<real_t> &discounts() const noexcept

discount. Returns the discount factor

bool last() const noexcept

last

Returns:

Private Members

std::vector<TimeStepTp> types_

the step types for the environments

std::vector<real_t> rewards_

The rewards received for every environment.

std::vector<state_type> obs_

Observations.

std::vector<real_t> discounts_

The discount factors for every environment.

std::unordered_map<std::string, std::any> extra_

extra_

template<int dim, typename Data>
class WayPoint : public rlenvscpp::utils::geom::GeomPoint<dim>
#include <waypoint.h>

Helper class to represent a waypoint.

Public Types

typedef Data data_type

Public Functions

WayPoint()

constructor

WayPoint(const GeomPoint<dim> &p, uint_t id, const data_type &data_ = data_type())

constructor

inline uint_t get_id() const

Return the id of the point.

inline data_type &get_data()

Writable reference to the data.

inline const data_type &get_data() const

Read reference to the data.

inline bool is_active() const

Returns true if the waypoint is active.

Private Members

uint_t id_
data_type data_
bool is_active_point_
template<typename LinkType>
class WaypointTrajectory

A container that represents a collection of way points linked together via a LinkType The LinkType defines how smooth the trajectory will look like.

Public Types

typedef link_type::w_point_type w_point_type

point iteration

Public Functions

WaypointTrajectory()

Constructor.

explicit WaypointTrajectory(uint_t n)

Constructor.

std::pair<real_t, link_type> distance(const w_point_type &p) const

Computes the minimum distance of the given point from the trajectory.

inline uint_t size() const

How many waypoints the pah has.

inline void reserve(uint_t n)

Reserve space for waypoints.

inline void clear()

clear the memory allocated for points and edges

inline bool empty() const

Returns true if the trajectory is empty.

Push a new link.

inline link_type &operator[](uint_t i)

Returns a read/write reference of the i-th link.

inline const link_type &operator[](uint_t i) const

Returns a read reference of the i-th link.

inline void resize(uint_t n)

Resize the underlying links.

inline link_iterator begin()

Raw node iteration.

inline link_iterator end()
inline const_link_iterator begin() const

Raw node iteration.

inline const_link_iterator end() const

Private Members

The segments of the path.

template<typename BaseInputAdapter, typename WideCharType>
class wide_string_input_adapter

Public Types

using char_type = char

Public Functions

inline wide_string_input_adapter(BaseInputAdapter base)
inline std::char_traits<char>::int_type get_character() noexcept

Private Functions

template<size_t T>
inline void fill_buffer()

Private Members

BaseInputAdapter base_adapter
std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}

a buffer for UTF-8 bytes

std::size_t utf8_bytes_index = 0

index to the utf8_codes array for the next valid byte

std::size_t utf8_bytes_filled = 0

number of valid bytes in the utf8_codes array

template<typename BaseInputAdapter, size_t T>
struct wide_string_input_helper
template<typename BaseInputAdapter>
struct wide_string_input_helper<BaseInputAdapter, 2>

Public Static Functions

static inline void fill_buffer(BaseInputAdapter &input, std::array<std::char_traits<char>::int_type, 4> &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
template<typename BaseInputAdapter>
struct wide_string_input_helper<BaseInputAdapter, 4>

Public Static Functions

static inline void fill_buffer(BaseInputAdapter &input, std::array<std::char_traits<char>::int_type, 4> &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
template<typename TimeStepType>
class with_rest_api_mixin

class synchronized_env_mixin

Public Types

typedef TimeStepType time_step_type

Public Functions

with_rest_api_mixin(const std::string &api_url, const std::string &resource_path)

Constructor.

with_rest_api_mixin(const with_rest_api_mixin &other)

Copy ctor.

virtual ~with_rest_api_mixin() = default

destructor

virtual time_step_type create_time_step_from_response_(const http::Response &response) const = 0

build the time step from the server response

virtual bool is_alive() const = 0

Query the environment server is the environment has been created.

inline std::string get_url() const noexcept

Returns the url the environment is using.

inline std::string get_api_url() const noexcept

Returns the url the environment is using.

inline std::string get_resource_path() const noexcept

The resource path.

Private Members

std::string api_url_
std::string resource_path_
namespace json_literals
namespace [anonymous]

namespace to hold default from_json function to see why this is required: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html

namespace better_enums

Functions

template<typename T> inline BETTER_ENUMS_CONSTEXPR_ T _default ()
template<> inline BETTER_ENUMS_CONSTEXPR_ const char * _default< const char * > ()
template<> inline BETTER_ENUMS_CONSTEXPR_ std::size_t _default< std::size_t > ()
template<typename CastTo, typename Element> static BETTER_ENUMS_CONSTEXPR_ optional< CastTo > _map_index (const Element *array, optional< std::size_t > index)
BETTER_ENUMS_IF_EXCEPTIONS (template< typename T > BETTER_ENUMS_CONSTEXPR_ static T _or_throw(optional< T > maybe, const char *message) { BETTER_ENUMS_OR_THROW }) template< typename T > BETTER_ENUMS_CONSTEXPR_ static T *_or_null(optional< T * > maybe)
template<typename T> static BETTER_ENUMS_CONSTEXPR_ T _or_zero (optional< T > maybe)
template<typename T, typename U> BETTER_ENUMS_CONSTEXPR_ U continue_with (T, U value)
inline BETTER_ENUMS_CONSTEXPR_ bool _ends_name (char c, std::size_t index=0)
inline BETTER_ENUMS_CONSTEXPR_ bool _has_initializer (const char *s, std::size_t index=0)
inline BETTER_ENUMS_CONSTEXPR_ std::size_t _constant_length (const char *s, std::size_t index=0)
inline BETTER_ENUMS_CONSTEXPR_ char _select (const char *from, std::size_t from_length, std::size_t index)
inline BETTER_ENUMS_CONSTEXPR_ char _to_lower_ascii (char c)
inline BETTER_ENUMS_CONSTEXPR_ bool _names_match (const char *stringizedName, const char *referenceName, std::size_t index=0)
inline BETTER_ENUMS_CONSTEXPR_ bool _names_match_nocase (const char *stringizedName, const char *referenceName, std::size_t index=0)
inline void _trim_names(const char *const *raw_names, const char **trimmed_names, char *storage, std::size_t count)
template<typename Enum, typename T> BETTER_ENUMS_CONSTEXPR_ map< Enum, T > make_map (T(*f)(Enum))

Variables

static BETTER_ENUMS_CONSTEXPR_ const char * _name_enders   = "= \t\n"
namespace boost
namespace detail

detail namespace with internal helper functions

This namespace collects functions that should not be exposed, implementations of some basic_json methods, and meta-programming helpers.

Since

version 2.1.0

Typedefs

template<typename ...Ts>
using void_t = typename make_void<Ts...>::type
template<template<class...> class Op, class ...Args>
using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t
template<template<class...> class Op, class ...Args>
using detected_t = typename detector<nonesuch, void, Op, Args...>::type
template<class Default, template<class...> class Op, class ...Args>
using detected_or = detector<Default, void, Op, Args...>
template<class Default, template<class...> class Op, class ...Args>
using detected_or_t = typename detected_or<Default, Op, Args...>::type
template<class Expected, template<class...> class Op, class ...Args>
using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>
template<class To, template<class...> class Op, class ...Args>
using is_detected_convertible = std::is_convertible<detected_t<Op, Args...>, To>
template<typename T>
using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type
template<bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type
template<size_t... Ints>
using index_sequence = integer_sequence<size_t, Ints...>
template<typename T, T N>
using make_integer_sequence = typename utility_internal::Gen<T, N>::type
template<size_t N>
using make_index_sequence = make_integer_sequence<size_t, N>
template<typename ...Ts>
using index_sequence_for = make_index_sequence<sizeof...(Ts)>
template<typename T>
using mapped_type_t = typename T::mapped_type
template<typename T>
using key_type_t = typename T::key_type
template<typename T>
using value_type_t = typename T::value_type
template<typename T>
using difference_type_t = typename T::difference_type
template<typename T>
using pointer_t = typename T::pointer
template<typename T>
using reference_t = typename T::reference
template<typename T>
using iterator_category_t = typename T::iterator_category
template<typename T, typename ...Args>
using to_json_function = decltype(T::to_json(std::declval<Args>()...))
template<typename T, typename ...Args>
using from_json_function = decltype(T::from_json(std::declval<Args>()...))
template<typename T, typename U> get_template_function = decltype(std::declval< T >().template get< U >())
template<typename T>
using detect_key_compare = typename T::key_compare
template<typename BasicJsonType>
using actual_object_comparator_t = typename actual_object_comparator<BasicJsonType>::type
template<typename R>
using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>
template<typename T>
using range_value_t = value_type_t<iterator_traits<iterator_t<T>>>
template<typename T>
using is_json_pointer = is_specialization_of<::nlohmann::json_pointer, uncvref_t<T>>
template<typename T>
using detect_is_transparent = typename T::is_transparent
template<typename Comparator, typename ObjectKeyType, typename KeyTypeCVRef, bool RequireTransparentComparator = true, bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
using is_usable_as_key_type = typename std::conditional<is_comparable<Comparator, ObjectKeyType, KeyTypeCVRef>::value && !(ExcludeObjectKeyType && std::is_same<KeyType, ObjectKeyType>::value) && (!RequireTransparentComparator || is_detected<detect_is_transparent, Comparator>::value) && !is_json_pointer<KeyType>::value, std::true_type, std::false_type>::type
template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true, bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
using is_usable_as_basic_json_key_type = typename std::conditional<is_usable_as_key_type<typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType>::value && !is_json_iterator_of<BasicJsonType, KeyType>::value, std::true_type, std::false_type>::type
template<typename ObjectType, typename KeyType>
using detect_erase_with_key_type = decltype(std::declval<ObjectType&>().erase(std::declval<KeyType>()))
template<typename BasicJsonType, typename KeyType>
using has_erase_with_key_type = typename std::conditional<is_detected<detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType>::value, std::true_type, std::false_type>::type
template<typename ...Types>
using all_integral = conjunction<std::is_integral<Types>...>
template<typename ...Types>
using all_signed = conjunction<std::is_signed<Types>...>
template<typename ...Types>
using all_unsigned = conjunction<std::is_unsigned<Types>...>
template<typename ...Types>
using same_sign = std::integral_constant<bool, all_signed<Types...>::value || all_unsigned<Types...>::value>
template<typename OfType, typename T>
using never_out_of_range = std::integral_constant<bool, (std::is_signed<OfType>::value && (sizeof(T) < sizeof(OfType))) || (same_sign<OfType, T>::value && sizeof(OfType) == sizeof(T))>
template<bool Value>
using bool_constant = std::integral_constant<bool, Value>
template<typename T>
using is_c_string_uncvref = is_c_string<uncvref_t<T>>
template<typename StringType, typename Arg>
using string_can_append = decltype(std::declval<StringType&>().append(std::declval<Arg&&>()))
template<typename StringType, typename Arg>
using detect_string_can_append = is_detected<string_can_append, StringType, Arg>
template<typename StringType, typename Arg>
using string_can_append_op = decltype(std::declval<StringType&>() += std::declval<Arg&&>())
template<typename StringType, typename Arg>
using detect_string_can_append_op = is_detected<string_can_append_op, StringType, Arg>
template<typename StringType, typename Arg>
using string_can_append_iter = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()))
template<typename StringType, typename Arg>
using detect_string_can_append_iter = is_detected<string_can_append_iter, StringType, Arg>
template<typename StringType, typename Arg>
using string_can_append_data = decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()))
template<typename StringType, typename Arg>
using detect_string_can_append_data = is_detected<string_can_append_data, StringType, Arg>
using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()))
template<typename T>
using null_function_t = decltype(std::declval<T&>().null())
template<typename T>
using boolean_function_t = decltype(std::declval<T&>().boolean(std::declval<bool>()))
template<typename T, typename Integer>
using number_integer_function_t = decltype(std::declval<T&>().number_integer(std::declval<Integer>()))
template<typename T, typename Unsigned>
using number_unsigned_function_t = decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()))
template<typename T, typename Float, typename String>
using number_float_function_t = decltype(std::declval<T&>().number_float(std::declval<Float>(), std::declval<const String&>()))
template<typename T, typename String>
using string_function_t = decltype(std::declval<T&>().string(std::declval<String&>()))
template<typename T, typename Binary>
using binary_function_t = decltype(std::declval<T&>().binary(std::declval<Binary&>()))
template<typename T>
using start_object_function_t = decltype(std::declval<T&>().start_object(std::declval<std::size_t>()))
template<typename T, typename String>
using key_function_t = decltype(std::declval<T&>().key(std::declval<String&>()))
template<typename T>
using end_object_function_t = decltype(std::declval<T&>().end_object())
template<typename T>
using start_array_function_t = decltype(std::declval<T&>().start_array(std::declval<std::size_t>()))
template<typename T>
using end_array_function_t = decltype(std::declval<T&>().end_array())
template<typename T, typename Exception>
using parse_error_function_t = decltype(std::declval<T&>().parse_error(std::declval<std::size_t>(), std::declval<const std::string&>(), std::declval<const Exception&>()))
template<typename BasicJsonType>
using parser_callback_t = std::function<bool(int, parse_event_t, BasicJsonType&)>
template<class T>
using json_base_class = typename std::conditional<std::is_same<T, void>::value, json_default_base, T>::type
template<typename CharType>
using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>

a type to simplify interfaces

Enums

enum class value_t : std::uint8_t

the JSON type enumeration

This enumeration collects the different JSON types. It is internally used to distinguish the stored values, and the functions basic_json::is_null(), basic_json::is_object(), basic_json::is_array(), basic_json::is_string(), basic_json::is_boolean(), basic_json::is_number() (with basic_json::is_number_integer(), basic_json::is_number_unsigned(), and basic_json::is_number_float()), basic_json::is_discarded(), basic_json::is_primitive(), and basic_json::is_structured() rely on it.

See also

see basic_json::basic_json(const value_t value_type) &#8212; create a JSON value with the default value for a given type

Since

version 1.0.0

Note

There are three enumeration entries (number_integer, number_unsigned, and number_float), because the library distinguishes these three types for numbers: basic_json::number_unsigned_t is used for unsigned integers, basic_json::number_integer_t is used for signed integers, and basic_json::number_float_t is used for floating-point numbers or to approximate integers which do not fit in the limits of their respective type.

Values:

enumerator null

null value

enumerator object

object (unordered set of name/value pairs)

enumerator array

array (ordered collection of values)

enumerator string

string value

enumerator boolean

boolean value

enumerator number_integer

number value (signed integer)

enumerator number_unsigned

number value (unsigned integer)

enumerator number_float

number value (floating-point)

enumerator binary

binary array (ordered collection of bytes)

enumerator discarded

discarded by the parser callback function

enum class input_format_t

the supported input formats

Values:

enumerator json
enumerator cbor
enumerator msgpack
enumerator ubjson
enumerator bson
enumerator bjdata
enum class cbor_tag_handler_t

how to treat CBOR tags

Values:

enumerator error

throw a parse_error exception in case of a tag

enumerator ignore

ignore tags

enumerator store

store tags as binary type

enum class parse_event_t : std::uint8_t

Values:

enumerator object_start

the parser read { and started to process a JSON object

enumerator object_end

the parser read } and finished processing a JSON object

enumerator array_start

the parser read [ and started to process a JSON array

enumerator array_end

the parser read ] and finished processing a JSON array

enumerator key

the parser read a key of a value in an object

enumerator value

the parser finished reading a JSON value

enum class error_handler_t

how to treat decoding errors

Values:

enumerator strict

throw a type_error exception in case of invalid UTF-8

enumerator replace

replace invalid UTF-8 sequences with U+FFFD

enumerator ignore

ignore invalid UTF-8 sequences

Functions

inline bool operator<(const value_t lhs, const value_t rhs) noexcept

comparison operator for JSON types

Returns an ordering that is similar to Python:

  • order: null < boolean < number < object < array < string < binary

  • furthermore, each type is not smaller than itself

  • discarded values are not comparable

  • binary is represented as a b”” string in python and directly comparable to a string; however, making a binary array directly comparable with a string would be surprising behavior in a JSON file.

Since

version 1.0.0

template<typename StringType>
inline void replace_substring(StringType &s, const StringType &f, const StringType &t)

replace all occurrences of a substring by another string

Since

version 2.0.0

Parameters:
  • s[inout] the string to manipulate; changed so that all occurrences of f are replaced with t

  • f[in] the substring to replace with t

  • t[in] the string to replace f

Pre:

The search string f must not be empty. This precondition is enforced with an assertion.

template<typename StringType>
inline StringType escape(StringType s)

string escaping as described in RFC 6901 (Sect. 4)

Note the order of escaping “~” to “~0” and “/” to “~1” is important.

Parameters:

s[in] string to escape

Returns:

escaped string

template<typename StringType>
static void unescape(StringType &s)

string unescaping as described in RFC 6901 (Sect. 4)

Note the order of escaping “~1” to “/” and “~0” to “~” is important.

Parameters:

s[in] string to unescape

Returns:

unescaped string

template<typename T, typename ...Args>
inline constexpr std::array<T, sizeof...(Args)> make_array(Args&&... args)
template<typename T, typename U, enable_if_t<!std::is_same<T, U>::value, int> = 0>
T conditional_static_cast(U value)
template<typename OfType, typename T>
inline constexpr bool value_in_range_of(T val)
inline std::size_t concat_length()
template<typename ...Args>
inline std::size_t concat_length(const char *cstr, const Args&... rest)
template<typename StringType, typename ...Args>
inline std::size_t concat_length(const StringType &str, const Args&... rest)
template<typename ...Args>
inline std::size_t concat_length(const char, const Args&... rest)
template<typename OutStringType>
inline void concat_into(OutStringType&)
template<typename OutStringType, typename Arg, typename ...Args, enable_if_t<!detect_string_can_append<OutStringType, Arg>::value && detect_string_can_append_op<OutStringType, Arg>::value, int> = 0>
inline void concat_into(OutStringType &out, Arg &&arg, Args&&... rest)
template<typename OutStringType, typename Arg, typename ...Args, enable_if_t<!detect_string_can_append<OutStringType, Arg>::value && !detect_string_can_append_op<OutStringType, Arg>::value && detect_string_can_append_iter<OutStringType, Arg>::value, int> = 0>
inline void concat_into(OutStringType &out, const Arg &arg, Args&&... rest)
template<typename OutStringType = std::string, typename ...Args>
inline OutStringType concat(Args&&... args)
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
template<typename BasicJsonType, typename ArithmeticType, enable_if_t<std::is_arithmetic<ArithmeticType>::value && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, int> = 0>
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename BasicJsonType::boolean_t &b)
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename BasicJsonType::string_t &s)
template<typename BasicJsonType, typename StringType, enable_if_t<std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value && !std::is_same<typename BasicJsonType::string_t, StringType>::value && !is_json_ref<StringType>::value, int> = 0>
inline void from_json(const BasicJsonType &j, StringType &s)
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename BasicJsonType::number_float_t &val)
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename BasicJsonType::number_unsigned_t &val)
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename BasicJsonType::number_integer_t &val)
template<typename BasicJsonType, typename EnumType, enable_if_t<std::is_enum<EnumType>::value, int> = 0>
inline void from_json(const BasicJsonType &j, EnumType &e)
template<typename BasicJsonType, typename T, typename Allocator, enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
inline void from_json(const BasicJsonType &j, std::forward_list<T, Allocator> &l)
template<typename BasicJsonType, typename T, enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
inline void from_json(const BasicJsonType &j, std::valarray<T> &l)
template<typename BasicJsonType, typename T, std::size_t N> auto from_json (const BasicJsonType &j, T(&arr)[N]) -> decltype(j.template get< T >(), void())
template<typename BasicJsonType>
inline void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag<3>)
template<typename BasicJsonType, typename T, std::size_t N> auto from_json_array_impl (const BasicJsonType &j, std::array< T, N > &arr, priority_tag< 2 >) -> decltype(j.template get< T >(), void())
template<typename BasicJsonType, typename ConstructibleArrayType, enable_if_t< std::is_assignable< ConstructibleArrayType &, ConstructibleArrayType >::value, int > = 0> auto from_json_array_impl (const BasicJsonType &j, ConstructibleArrayType &arr, priority_tag< 1 >) -> decltype(arr.reserve(std::declval< typename ConstructibleArrayType::size_type >()), j.template get< typename ConstructibleArrayType::value_type >(), void())
template<typename BasicJsonType, typename ConstructibleArrayType, enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, int> = 0>
inline void from_json_array_impl(const BasicJsonType &j, ConstructibleArrayType &arr, priority_tag<0>)
template<typename BasicJsonType, typename ConstructibleArrayType, enable_if_t< is_constructible_array_type< BasicJsonType, ConstructibleArrayType >::value &&!is_constructible_object_type< BasicJsonType, ConstructibleArrayType >::value &&!is_constructible_string_type< BasicJsonType, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, typename BasicJsonType::binary_t >::value &&!is_basic_json< ConstructibleArrayType >::value, int > = 0> auto from_json (const BasicJsonType &j, ConstructibleArrayType &arr) -> decltype(from_json_array_impl(j, arr, priority_tag< 3 > {}), j.template get< typename ConstructibleArrayType::value_type >(), void())
template<typename BasicJsonType, typename T, std::size_t... Idx>
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag<std::array<T, sizeof...(Idx)>>, index_sequence<Idx...>)
template<typename BasicJsonType, typename T, std::size_t N>
auto from_json(BasicJsonType &&j, identity_tag<std::array<T, N>> tag) -> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N>{}))
template<typename BasicJsonType>
inline void from_json(const BasicJsonType &j, typename BasicJsonType::binary_t &bin)
template<typename BasicJsonType, typename ConstructibleObjectType, enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
inline void from_json(const BasicJsonType &j, ConstructibleObjectType &obj)
template<typename BasicJsonType, typename ArithmeticType, enable_if_t<std::is_arithmetic<ArithmeticType>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, int> = 0>
inline void from_json(const BasicJsonType &j, ArithmeticType &val)
template<typename BasicJsonType, typename ...Args, std::size_t... Idx>
std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType &&j, index_sequence<Idx...>)
template<typename BasicJsonType, class A1, class A2>
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType &&j, identity_tag<std::pair<A1, A2>>, priority_tag<0>)
template<typename BasicJsonType, typename A1, typename A2>
inline void from_json_tuple_impl(BasicJsonType &&j, std::pair<A1, A2> &p, priority_tag<1>)
template<typename BasicJsonType, typename ...Args>
std::tuple<Args...> from_json_tuple_impl(BasicJsonType &&j, identity_tag<std::tuple<Args...>>, priority_tag<2>)
template<typename BasicJsonType, typename ...Args>
inline void from_json_tuple_impl(BasicJsonType &&j, std::tuple<Args...> &t, priority_tag<3>)
template<typename BasicJsonType, typename TupleRelated>
auto from_json(BasicJsonType &&j, TupleRelated &&t) -> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3>{}))
template<typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
inline void from_json(const BasicJsonType &j, std::map<Key, Value, Compare, Allocator> &m)
template<typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
inline void from_json(const BasicJsonType &j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator> &m)
template<typename string_type>
void int_to_string(string_type &target, std::size_t value)
template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
auto get(const nlohmann::detail::iteration_proxy_value<IteratorType> &i) -> decltype(i.key())
template<typename BasicJsonType, typename T, enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
inline void to_json(BasicJsonType &j, T b) noexcept
template<typename BasicJsonType, typename BoolRef, enable_if_t<((std::is_same<std::vector<bool>::reference, BoolRef>::value && !std::is_same<std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value) || (std::is_same<std::vector<bool>::const_reference, BoolRef>::value && !std::is_same<detail::uncvref_t<std::vector<bool>::const_reference>, typename BasicJsonType::boolean_t>::value)) && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value, int> = 0>
inline void to_json(BasicJsonType &j, const BoolRef &b) noexcept
template<typename BasicJsonType, typename CompatibleString, enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
inline void to_json(BasicJsonType &j, const CompatibleString &s)
template<typename BasicJsonType>
inline void to_json(BasicJsonType &j, typename BasicJsonType::string_t &&s)
template<typename BasicJsonType, typename FloatType, enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
inline void to_json(BasicJsonType &j, FloatType val) noexcept
template<typename BasicJsonType, typename CompatibleNumberUnsignedType, enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
inline void to_json(BasicJsonType &j, CompatibleNumberUnsignedType val) noexcept
template<typename BasicJsonType, typename CompatibleNumberIntegerType, enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
inline void to_json(BasicJsonType &j, CompatibleNumberIntegerType val) noexcept
template<typename BasicJsonType, typename EnumType, enable_if_t<std::is_enum<EnumType>::value, int> = 0>
inline void to_json(BasicJsonType &j, EnumType e) noexcept
template<typename BasicJsonType>
inline void to_json(BasicJsonType &j, const std::vector<bool> &e)
template<typename BasicJsonType, typename CompatibleArrayType, enable_if_t<is_compatible_array_type<BasicJsonType, CompatibleArrayType>::value && !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value && !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value && !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value && !is_basic_json<CompatibleArrayType>::value, int> = 0>
inline void to_json(BasicJsonType &j, const CompatibleArrayType &arr)
template<typename BasicJsonType>
inline void to_json(BasicJsonType &j, const typename BasicJsonType::binary_t &bin)
template<typename BasicJsonType, typename T, enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
inline void to_json(BasicJsonType &j, const std::valarray<T> &arr)
template<typename BasicJsonType>
inline void to_json(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
template<typename BasicJsonType, typename CompatibleObjectType, enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value && !is_basic_json<CompatibleObjectType>::value, int> = 0>
inline void to_json(BasicJsonType &j, const CompatibleObjectType &obj)
template<typename BasicJsonType>
inline void to_json(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
template<typename BasicJsonType, typename T, std::size_t N, enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, const T (&)[N]>::value, int> = 0>
inline void to_json(BasicJsonType &j, const T (&arr)[N])
template<typename BasicJsonType, typename T1, typename T2, enable_if_t<std::is_constructible<BasicJsonType, T1>::value && std::is_constructible<BasicJsonType, T2>::value, int> = 0>
inline void to_json(BasicJsonType &j, const std::pair<T1, T2> &p)
template<typename BasicJsonType, typename T, enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
inline void to_json(BasicJsonType &j, const T &b)
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
inline void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence<Idx...>)
inline std::size_t combine(std::size_t seed, std::size_t h) noexcept
template<typename BasicJsonType>
std::size_t hash(const BasicJsonType &j)

hash a JSON value

The hash function tries to rely on std::hash where possible. Furthermore, the type of the JSON value is taken into account to have different hash values for null, 0, 0U, and false, etc.

Template Parameters:

BasicJsonTypebasic_json specialization

Parameters:

j – JSON value to hash

Returns:

hash value of j

template<typename IteratorType>
iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
template<typename ContainerType>
container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(const ContainerType &container)
inline file_input_adapter input_adapter(std::FILE *file)
inline input_stream_adapter input_adapter(std::istream &stream)
inline input_stream_adapter input_adapter(std::istream &&stream)
template<typename CharT, typename std::enable_if<std::is_pointer<CharT>::value && !std::is_array<CharT>::value && std::is_integral<typename std::remove_pointer<CharT>::type>::value && sizeof(typename std::remove_pointer<CharT>::type) == 1, int>::type = 0>
contiguous_bytes_input_adapter input_adapter(CharT b)
template<typename T, std::size_t N>
auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N))
static inline bool little_endianness(int num = 1) noexcept

determine system byte order

Returns:

true if and only if system’s byte order is little endian

template<typename FloatType> JSON_HEDLEY_RETURNS_NON_NULL char * to_chars (char *first, const char *last, FloatType value)

generates a decimal representation of the floating-point number value in [first, last).

The format of the resulting decimal representation is similar to printf’s g format. Returns an iterator pointing past-the-end of the decimal representation.

Note

The input number must be finite, i.e. NaN’s and Inf’s are not supported.

Note

The buffer must be large enough.

Note

The result is NOT null-terminated.

namespace container_input_adapter_factory_impl
namespace dtoa_impl

implements the Grisu2 algorithm for binary to decimal floating-point conversion.

This implementation is a slightly modified version of the reference implementation which may be obtained from http://florian.loitsch.com/publications (bench.tar.gz).

The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch.

For a detailed description of the algorithm see:

[1] Loitsch, “Printing Floating-Point Numbers Quickly and Accurately with

Integers”, Proceedings of the ACM SIGPLAN 2010 Conference on Programming Language Design and Implementation, PLDI 2010 [2] Burger, Dybvig, “Printing Floating-Point Numbers Quickly and Accurately”, Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation, PLDI 1996

Functions

template<typename Target, typename Source>
Target reinterpret_bits(const Source source)
template<typename FloatType>
boundaries compute_boundaries(FloatType value)

Compute the (normalized) diyfp representing the input number ‘value’ and its boundaries.

Pre:

value must be finite and positive

inline cached_power get_cached_power_for_binary_exponent(int e)

For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c satisfies (Definition 3.2 from [1])

 alpha <= e_c + e + q <= gamma.

inline int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)

For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. For n == 0, returns 1 and sets pow10 := 1.

inline void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
inline void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)

Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. M- and M+ must be normalized and share the same exponent -60 <= e <= -32.

inline void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)

v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10.

template<typename FloatType>
void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value)

v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10.

inline JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent (char *buf, int e)

appends a decimal representation of e to buf

Returns:

a pointer to the element following the exponent.

Pre:

-1000 < e < 1000

inline JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer (char *buf, int len, int decimal_exponent, int min_exp, int max_exp)

prettify v = buf * 10^decimal_exponent

If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point notation. Otherwise it will be printed in exponential notation.

Pre:

min_exp < 0

Pre:

max_exp > 0

Variables

constexpr int kAlpha = -60
constexpr int kGamma = -32
namespace impl

Functions

template<typename T>
inline constexpr bool is_c_string()
template<typename T>
inline constexpr bool is_transparent()
namespace utility_internal
namespace http

Typedefs

using HeaderField = std::pair<std::string, std::string>
using HeaderFields = std::vector<HeaderField>

Enums

enum class InternetProtocol : std::uint8_t

Values:

enumerator v4
enumerator v6

Functions

inline int getLastError() noexcept
constexpr int getAddressFamily(const InternetProtocol internetProtocol)
template<typename C>
constexpr bool isWhiteSpaceChar(const C c) noexcept
template<typename C>
constexpr bool isDigitChar(const C c) noexcept
template<typename C>
constexpr bool isAlphaChar(const C c) noexcept
template<typename C>
constexpr bool isTokenChar(const C c) noexcept
template<typename C>
constexpr bool isVisibleChar(const C c) noexcept
template<typename C>
constexpr bool isObsoleteTextChar(const C c) noexcept
template<class Iterator>
Iterator skipWhiteSpaces(const Iterator begin, const Iterator end)
template<typename T, typename C, typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr>
constexpr T digitToUint(const C c)
template<typename T, typename C, typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr>
constexpr T hexDigitToUint(const C c)
template<class Iterator>
Uri parseUri(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, HttpVersion> parseHttpVersion(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, std::uint16_t> parseStatusCode(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, std::string> parseReasonPhrase(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, std::string> parseToken(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, std::string> parseFieldValue(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, std::string> parseFieldContent(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, HeaderField> parseHeaderField(const Iterator begin, const Iterator end)
template<class Iterator>
std::pair<Iterator, Status> parseStatusLine(const Iterator begin, const Iterator end)
template<typename T, class Iterator, typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr>
T stringToUint(const Iterator begin, const Iterator end)
template<typename T, class Iterator, typename std::enable_if<std::is_unsigned<T>::value>::type* = nullptr>
T hexStringToUint(const Iterator begin, const Iterator end)
inline std::string encodeRequestLine(const std::string &method, const std::string &target)
inline std::string encodeHeaderFields(const HeaderFields &headerFields)
template<class Iterator>
std::string encodeBase64(const Iterator begin, const Iterator end)
inline std::vector<std::uint8_t> encodeHtml(const Uri &uri, const std::string &method, const std::vector<uint8_t> &body, HeaderFields headerFields)
namespace detail
namespace literals
namespace json_literals
namespace nlohmann
namespace detail
namespace rlenvscpp

todo write docs

Implements the Gridworld environment from the book Deep Reinforcement Learning in Action by Manning publications. You can find the original environment here: https://github.com/DeepReinforcementLearning/DeepReinforcementLearningInAction

Typedefs

typedef double real_t

real_t

typedef float float_t

float

typedef int int_t

integer type

typedef long int lint_t

long int type

typedef std::size_t uint_t

uint_t

template<typename T>
using DynMat = Eigen::MatrixX<T>
using RealMat3d = Eigen::Matrix3<real_t>

Dynamic×3 matrix of type double.

using FloatMat3d = Eigen::Matrix3<float_t>
template<typename T>
using DynVec = Eigen::RowVectorX<T>
using FloatVec = DynVec<float_t>

single precision floating point vector

using RealVec = DynVec<real_t>

double precision floating point vector

using STD_FloatVec = std::vector<float_t>

single precision std::vector

using STD_RealVec = std::vector<real_t>

double precision std::vector

template<typename T>
using ColVec = Eigen::VectorX<T>

Column vector. Some maths operations are easier using column vectors rather than DynVec.

using RealColVec = ColVec<real_t>
using FoatColVec = ColVec<float_t>
using RealColVec3d = Eigen::Vector3d
using FloatColVec3d = Eigen::Vector3f

Enums

enum class TimeStepTp : uint_t

The TimeStepTp enum.

Values:

enumerator FIRST
enumerator MID
enumerator LAST
enumerator INVALID_TYPE
enum class DeviceType

Device type.

Values:

enumerator INVALID_TYPE
enumerator CPU
enumerator GPU

Functions

template<typename StateTp>
inline std::ostream &operator<<(std::ostream &out, const TimeStep<StateTp> &step)
template<typename T>
std::ostream &operator<<(std::ostream &out, const TimeStep<std::vector<T>> &step)
template<typename StateTp>
inline std::ostream &operator<<(std::ostream &out, const VectorTimeStep<StateTp> &step)
namespace consts

Variables

const uint_t INVALID_ID = static_cast<uint_t>(-1)

INVALID_ID.

const std::string INVALID_STR = std::string("INVALID")

Invalid string.

const real_t TOLERANCE = 1.0e-8

Tolerance to use around the library.

namespace maths

Variables

const real_t PI = 3.14159265359

The Pi constant.

const real_t G = 9.82

Acceleration due to gravity m/secs.

namespace dynamics

Functions

template<int dim>
inline std::ostream &operator<<(std::ostream &out, const SysState<dim> &state)
namespace envs

Functions

template<typename EnvType, typename ActionSelector>
std::vector<typename EnvType::time_step_type> create_trajectory(EnvType &env, ActionSelector &action_selector, uint_t max_steps)

Todo:

write docs

namespace connect2
namespace gdrl
namespace grid_world

Enums

enum class GridWorldInitType : int

Values:

enumerator STATIC
enumerator RANDOM
enumerator PLAYER
enumerator INVALID_TYPE
enum class GridWorldActionType : uint_t

Values:

enumerator UP
enumerator DOWN
enumerator LEFT
enumerator RIGHT
enumerator INVALID_TYPE

Functions

GridWorldInitType from_string(const std::string &gw_init_type)
namespace detail

Typedefs

typedef std::pair<int, int> board_position

Models a position on the board.

typedef std::vector<std::vector<std::vector<real_t>>> board_state_type

Array specifying the state of the board.

using board_mask = board_piece

The BoardPiece struct.

Enums

enum board_component_type

The BoardComponentType enum.

Values:

enumerator PLAYER
enumerator GOAL
enumerator PIT
enumerator WALL
enum board_move_type

The MoveType enum.

Values:

enumerator VALID
enumerator INVALID
enumerator LOST_GAME

Functions

bool validate_board(const board &b)
bool operator==(const board_position &p1, const board_position &p2)

Test if two positions are equal.

bool operator!=(const board_position &p1, const board_position &p2)

Test if two positions are equal.

board_position operator+(const board_position &p1, const board_position &p2)

Add two positions and return their result.

uint_t max(const board_position &p)

Returns the max component of a position.

uint_t min(const board_position &p)

Returns the min component of a position.

namespace gym_pybullet_drones
namespace gymnasium
namespace detail_
namespace rigid_bodies
namespace utils

Functions

inline std::ostream &operator<<(std::ostream &out, const IterativeAlgorithmResult &result)
template<typename OutT>
OutT resolve(const std::string &name, const std::map<std::string, std::any> &input)
namespace geom

Enums

enum class BBType

The BBType enum. Helper enumeration for distinguishing boundin box types e.g. for rigid bodies.

Values:

enumerator RECTANGLE
enumerator CIRCLE
enumerator SPHERE

Functions

template<int spacedim, typename T>
inline std::ostream &operator<<(std::ostream &out, const GeomPoint<spacedim, T> &p)

free functions that work on the GeomPoint<spacedim,T> class

Prints the values of the GeomPoint in the

template<int spacedim, typename T>
const GeomPoint<spacedim, T> scale(const GeomPoint<spacedim, T> &t, T factor)

scale the given point by facto and returns a copyr. This function does not change the entries of t.

template<int spacedim, typename T>
const GeomPoint<spacedim, T> scale(const GeomPoint<spacedim, T> &t, const std::vector<T> &factors)

scale the given point by the factors in vector

template<int spacedim, typename T>
const GeomPoint<spacedim, T> abs(const GeomPoint<spacedim, T> &t)

Return a point having the absolute values of the given point object.

template<int spacedim, typename T>
const GeomPoint<spacedim, T> operator*(T factor, const GeomPoint<spacedim, T> &t)

Allow multiplication from left with a factor.

template<int spacedim, typename T>
const GeomPoint<spacedim, T> operator*(const GeomPoint<spacedim, T> &t, T factor)
template<int spacedim, typename T>
const GeomPoint<spacedim, T> operator/(const GeomPoint<spacedim, T> &t, T factor)
template<int spacedim, typename T>
const GeomPoint<spacedim, T> operator+(const GeomPoint<spacedim, T> &t1, const GeomPoint<spacedim, T> &t2)
template<int spacedim, typename T>
const GeomPoint<spacedim, T> operator-(const GeomPoint<spacedim, T> &t1, const GeomPoint<spacedim, T> &t2)
template<int spacedim, typename T>
bool operator==(const GeomPoint<spacedim, T> &t1, const GeomPoint<spacedim, T> &t2)
template<int spacedim, typename T>
bool operator!=(const GeomPoint<spacedim, T> &t1, const GeomPoint<spacedim, T> &t2)
namespace io

Functions

template<typename T>
std::ostream &print_vector(std::ostream &out, const std::vector<T> &obs)
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &obs)
namespace maths

Functions

template<typename T>
int_t sign(const T &expr)

Returns the sign of the expression.

template<typename T>
int_t sign(const T &expr1, const T &expr2)
template<typename T>
T sum_sqr(const DynVec<T> &vec)

Compute the sum of squares of the elements of the given vector.

template<typename T>
T sqr(const T &v)
namespace stats
namespace trajectory
namespace unit_converter

Functions

real_t rpm_to_angular_speed(uint_t rpm)

Convert RPM to angular speed in m/s.

real_t angular_speed_to_linear_speed(real_t r, real_t w)

Convert RPM to angular speed in m/s.

real_t rad_to_degrees(real_t rad)

Convert radians to degrees.

real_t degrees_to_rad(real_t degs)

Convert degrees to radians.

namespace std

Functions

inline NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap (nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)

exchanges the values of two JSON objects

namespace conditional
file bicycle_vehicle_model_dynamics.cpp
file bicycle_vehicle_model_dynamics.h
#include “rlenvs/rlenvs_types_v2.h
#include <any>
#include <map>
#include <string>
file diff_drive_dynamics.cpp
#include “rlenvs/rlenvs_consts.h
#include <cmath>
#include <iostream>
file diff_drive_dynamics.h
#include “rlenvs/rlenvs_types_v2.h
#include <array>
#include <map>
#include <any>
file dynamics_matrix_descriptor.cpp
#include <stdexcept>
file dynamics_matrix_descriptor.h
#include “rlenvs/rlenvs_types_v2.h
#include <map>
#include <string>
file motion_model_base.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include “boost/noncopyable.hpp”
#include <memory>
#include <vector>
#include <string>
file quadrotor_dynamics.cpp
#include “rlenvs/rlenvs_consts.h
#include <cmath>
file quadrotor_dynamics.h
#include “rlenvs/rlenvs_types_v2.h
#include <any>
file system_state.h
#include “rlenvs/rlenvs_types_v2.h
#include <string>
#include <array>
#include <utility>
#include <algorithm>
#include <vector>
#include <ostream>
#include <stdexcept>
#include <iomanip>
file apiserver.cpp
#include “rlenvs/rlenvs_consts.h
#include <string>
#include <stdexcept>
file apiserver.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include <string>
#include <vector>
#include <any>
#include <unordered_map>
file connect2_env.cpp
#include “rlenvs/envs/time_step.h
#include <algorithm>
#include <unordered_map>
#include <stdexcept>
#include <any>
#include <memory>
file connect2_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_types.h
#include “rlenvs/envs/env_base.h
#include <boost/noncopyable.hpp>
#include <vector>
#include <string>
#include <unordered_map>
#include <memory>
file env_base.h
#include “rlenvs/rlenvs_consts.h
#include <boost/noncopyable.hpp>
#include <unordered_map>
#include <any>
#include <string>
#include <memory>
#include <type_traits>
file env_types.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/space_type.h
file envs_utils.h
#include “rlenvs/rlenvs_types_v2.h
#include <vector>
file gym_walk.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_types.h
#include “rlenvs/envs/env_base.h
#include <boost/noncopyable.hpp>
#include <vector>
#include <tuple>
#include <string>
#include <any>
#include <unordered_map>
#include <memory>
file grid_world_env.cpp
#include <string>
#include <random>
#include <utility>
#include <set>
file grid_world_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_base.h
#include “rlenvs/envs/space_type.h
#include <vector>
#include <string>
#include <utility>
#include <unordered_map>
#include <map>
#include <any>
#include <memory>
file quadcopter_sim_env.cpp
#include <iostream>
file quadcopter_sim_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/env_base.h
#include “rlenvs/time_step.h”
#include <boost/noncopyable.hpp>
#include <unordered_map>
#include <any>
#include <string>
file acrobot_env.cpp
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
file acrobot_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_types.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
file cart_pole_env.cpp
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
file cart_pole_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_types.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
file mountain_car_env.cpp
#include “rlenvs/envs/time_step.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
file mountain_car_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_types.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
#include <unordered_map>
file pendulum_env.cpp
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
file pendulum_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include “rlenvs/envs/env_types.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
file state_aggregation_cart_pole_env.cpp
file state_aggregation_cart_pole_env.h
#include “rlenvs/rlenvs_types_v2.h
#include <string>
#include <utility>
#include <vector>
#include <tuple>
file acrobot_vec_env.cpp
#include <iostream>
file acrobot_vec_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/space_type.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
file gymnasium_env_base.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/env_base.h
#include <boost/noncopyable.hpp>
#include <string>
#include <string_view>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <any>
file gymnasium_vector_env_base.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/env_types.h
#include <stdexcept>
file black_jack_env.cpp
#include <iostream>
#include <typeinfo>
#include <memory>
file black_jack_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
#include <unordered_map>
file cliff_world_env.cpp
#include <iostream>
#include <any>
#include <memory>
file cliff_world_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include <string>
#include <tuple>
#include <any>
#include <unordered_map>
file frozen_lake_env.cpp
#include <iostream>
#include <memory>
file frozen_lake_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include <string>
#include <vector>
#include <tuple>
#include <any>
#include <unordered_map>
file taxi_env.cpp
#include <memory>
file taxi_env.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/time_step.h
#include <string>
#include <any>
#include <unordered_map>
file toy_text_base.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/envs/env_types.h
#include <string>
#include <vector>
#include <tuple>
#include <unordered_map>
#include <any>
file space_type.h
#include “rlenvs/rlenvs_types_v2.h
#include <random>
#include <vector>
#include <type_traits>
file state_aggregation_env_base.h
#include “rlenvs/rlenvs_types_v2.h
#include <vector>
#include <string>
file synchronized_env_mixin.h
#include <any>
#include <string>
#include <unordered_map>
file time_step.h
#include “rlenvs/rlenvs_types_v2.h
#include <string>
#include <any>
#include <unordered_map>
#include <stdexcept>
#include <vector>
#include <ostream>
file time_step_type.cpp
#include <algorithm>
#include <iterator>
#include <iostream>
file time_step_type.h
#include “rlenvs/rlenvs_types_v2.h
#include <string>
#include <vector>
file vector_time_step.h
#include “rlenvs/rlenvs_types_v2.h
#include <vector>
#include <algorithm>
#include <any>
#include <unordered_map>
#include <ostream>
file with_rest_api_mixin.h
#include <string>
file enum.h
#include <cstddef>
#include <cstring>
#include <iosfwd>
#include <stdexcept>

Defines

BETTER_ENUMS_ENUM_H
BETTER_ENUMS_IGNORE_OLD_CAST_HEADER
BETTER_ENUMS_IGNORE_OLD_CAST_BEGIN
BETTER_ENUMS_IGNORE_OLD_CAST_END
BETTER_ENUMS_IGNORE_ATTRIBUTES_HEADER
BETTER_ENUMS_IGNORE_ATTRIBUTES_BEGIN
BETTER_ENUMS_IGNORE_ATTRIBUTES_END
BETTER_ENUMS_CONSTEXPR_
BETTER_ENUMS_NULLPTR
BETTER_ENUMS_IF_EXCEPTIONS(x)
BETTER_ENUMS_UNUSED
BETTER_ENUMS_PP_MAP(macro, data, ...)
BETTER_ENUMS_PP_MAP_VAR_COUNT(count)
BETTER_ENUMS_APPLY(macro, ...)
BETTER_ENUMS_ID(x)
BETTER_ENUMS_M1(m, d, x)
BETTER_ENUMS_M2(m, d, x, ...)
BETTER_ENUMS_M3(m, d, x, ...)
BETTER_ENUMS_M4(m, d, x, ...)
BETTER_ENUMS_M5(m, d, x, ...)
BETTER_ENUMS_M6(m, d, x, ...)
BETTER_ENUMS_M7(m, d, x, ...)
BETTER_ENUMS_M8(m, d, x, ...)
BETTER_ENUMS_M9(m, d, x, ...)
BETTER_ENUMS_M10(m, d, x, ...)
BETTER_ENUMS_M11(m, d, x, ...)
BETTER_ENUMS_M12(m, d, x, ...)
BETTER_ENUMS_M13(m, d, x, ...)
BETTER_ENUMS_M14(m, d, x, ...)
BETTER_ENUMS_M15(m, d, x, ...)
BETTER_ENUMS_M16(m, d, x, ...)
BETTER_ENUMS_M17(m, d, x, ...)
BETTER_ENUMS_M18(m, d, x, ...)
BETTER_ENUMS_M19(m, d, x, ...)
BETTER_ENUMS_M20(m, d, x, ...)
BETTER_ENUMS_M21(m, d, x, ...)
BETTER_ENUMS_M22(m, d, x, ...)
BETTER_ENUMS_M23(m, d, x, ...)
BETTER_ENUMS_M24(m, d, x, ...)
BETTER_ENUMS_M25(m, d, x, ...)
BETTER_ENUMS_M26(m, d, x, ...)
BETTER_ENUMS_M27(m, d, x, ...)
BETTER_ENUMS_M28(m, d, x, ...)
BETTER_ENUMS_M29(m, d, x, ...)
BETTER_ENUMS_M30(m, d, x, ...)
BETTER_ENUMS_M31(m, d, x, ...)
BETTER_ENUMS_M32(m, d, x, ...)
BETTER_ENUMS_M33(m, d, x, ...)
BETTER_ENUMS_M34(m, d, x, ...)
BETTER_ENUMS_M35(m, d, x, ...)
BETTER_ENUMS_M36(m, d, x, ...)
BETTER_ENUMS_M37(m, d, x, ...)
BETTER_ENUMS_M38(m, d, x, ...)
BETTER_ENUMS_M39(m, d, x, ...)
BETTER_ENUMS_M40(m, d, x, ...)
BETTER_ENUMS_M41(m, d, x, ...)
BETTER_ENUMS_M42(m, d, x, ...)
BETTER_ENUMS_M43(m, d, x, ...)
BETTER_ENUMS_M44(m, d, x, ...)
BETTER_ENUMS_M45(m, d, x, ...)
BETTER_ENUMS_M46(m, d, x, ...)
BETTER_ENUMS_M47(m, d, x, ...)
BETTER_ENUMS_M48(m, d, x, ...)
BETTER_ENUMS_M49(m, d, x, ...)
BETTER_ENUMS_M50(m, d, x, ...)
BETTER_ENUMS_M51(m, d, x, ...)
BETTER_ENUMS_M52(m, d, x, ...)
BETTER_ENUMS_M53(m, d, x, ...)
BETTER_ENUMS_M54(m, d, x, ...)
BETTER_ENUMS_M55(m, d, x, ...)
BETTER_ENUMS_M56(m, d, x, ...)
BETTER_ENUMS_M57(m, d, x, ...)
BETTER_ENUMS_M58(m, d, x, ...)
BETTER_ENUMS_M59(m, d, x, ...)
BETTER_ENUMS_M60(m, d, x, ...)
BETTER_ENUMS_M61(m, d, x, ...)
BETTER_ENUMS_M62(m, d, x, ...)
BETTER_ENUMS_M63(m, d, x, ...)
BETTER_ENUMS_M64(m, d, x, ...)
BETTER_ENUMS_PP_COUNT_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, count, ...)
BETTER_ENUMS_PP_COUNT(...)
BETTER_ENUMS_ITERATE(X, f, l)
BETTER_ENUMS_OR_THROW
BETTER_ENUMS_EAT_ASSIGN_SINGLE(EnumType, index, expression)
BETTER_ENUMS_EAT_ASSIGN(EnumType, ...)
BETTER_ENUMS_STRINGIZE_SINGLE(ignored, index, expression)
BETTER_ENUMS_STRINGIZE(...)
BETTER_ENUMS_RESERVE_STORAGE_SINGLE(ignored, index, expression)
BETTER_ENUMS_RESERVE_STORAGE(...)
BETTER_ENUMS_NS(EnumType)
BETTER_ENUMS_COPY_CONSTRUCTOR(Enum)
BETTER_ENUMS_CLASS_ATTRIBUTE
BETTER_ENUMS_TYPE(SetUnderlyingType, SwitchType, GenerateSwitchType, GenerateStrings, ToStringConstexpr, DeclareInitialize, DefineInitialize, CallInitialize, Enum, Underlying, ...)
BETTER_ENUMS_CXX98_UNDERLYING_TYPE(Underlying)
BETTER_ENUMS_CXX11_UNDERLYING_TYPE(Underlying)
BETTER_ENUMS_LEGACY_UNDERLYING_TYPE(Underlying)
BETTER_ENUMS_REGULAR_ENUM_SWITCH_TYPE(Type)
BETTER_ENUMS_ENUM_CLASS_SWITCH_TYPE(Type)
BETTER_ENUMS_REGULAR_ENUM_SWITCH_TYPE_GENERATE(Underlying, ...)
BETTER_ENUMS_ENUM_CLASS_SWITCH_TYPE_GENERATE(Underlying, ...)
BETTER_ENUMS_CXX98_TRIM_STRINGS_ARRAYS(Enum, ...)
BETTER_ENUMS_CXX11_PARTIAL_CONSTEXPR_TRIM_STRINGS_ARRAYS(Enum, ...)
BETTER_ENUMS_CXX11_FULL_CONSTEXPR_TRIM_STRINGS_ARRAYS(Enum, ...)
BETTER_ENUMS_NO_CONSTEXPR_TO_STRING_KEYWORD
BETTER_ENUMS_CONSTEXPR_TO_STRING_KEYWORD
BETTER_ENUMS_DO_DECLARE_INITIALIZE
BETTER_ENUMS_DECLARE_EMPTY_INITIALIZE
BETTER_ENUMS_DO_DEFINE_INITIALIZE(Enum)
BETTER_ENUMS_DO_NOT_DEFINE_INITIALIZE(Enum)
BETTER_ENUMS_DO_CALL_INITIALIZE(value)
BETTER_ENUMS_DO_NOT_CALL_INITIALIZE(value)
BETTER_ENUMS_DEFAULT_SWITCH_TYPE
BETTER_ENUMS_DEFAULT_SWITCH_TYPE_GENERATE
BETTER_ENUMS_DEFAULT_CONSTRUCTOR(Enum)
BETTER_ENUM(Enum, Underlying, ...)
BETTER_ENUMS_DECLARE_STD_HASH(type)
file HTTPRequest.hpp
#include <cctype>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <array>
#include <chrono>
#include <functional>
#include <map>
#include <memory>
#include <stdexcept>
#include <string>
#include <system_error>
#include <type_traits>
#include <vector>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
file json.hpp
#include <algorithm>
#include <cstddef>
#include <functional>
#include <initializer_list>
#include <iosfwd>
#include <iterator>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <forward_list>
#include <map>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <valarray>
#include <exception>
#include <stdexcept>
#include <cstdint>
#include <cstdlib>
#include <cassert>
#include <limits>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <istream>
#include <clocale>
#include <cctype>
#include <cerrno>
#include <ios>
#include <ostream>
#include <iomanip>

lexicographical comparison operators

JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)

Defines

NLOHMANN_JSON_VERSION_MAJOR
NLOHMANN_JSON_VERSION_MINOR
NLOHMANN_JSON_VERSION_PATCH
JSON_DIAGNOSTICS
JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
NLOHMANN_JSON_NAMESPACE_NO_VERSION
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b)
NLOHMANN_JSON_ABI_TAGS
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch)
NLOHMANN_JSON_NAMESPACE_VERSION
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
NLOHMANN_JSON_NAMESPACE_CONCAT(a, b)
NLOHMANN_JSON_NAMESPACE
NLOHMANN_JSON_NAMESPACE_BEGIN
NLOHMANN_JSON_NAMESPACE_END
JSON_HEDLEY_VERSION
JSON_HEDLEY_STRINGIFY_EX(x)
JSON_HEDLEY_STRINGIFY(x)
JSON_HEDLEY_CONCAT_EX(a, b)
JSON_HEDLEY_CONCAT(a, b)
JSON_HEDLEY_CONCAT3_EX(a, b, c)
JSON_HEDLEY_CONCAT3(a, b, c)
JSON_HEDLEY_VERSION_ENCODE(major, minor, revision)
JSON_HEDLEY_VERSION_DECODE_MAJOR(version)
JSON_HEDLEY_VERSION_DECODE_MINOR(version)
JSON_HEDLEY_VERSION_DECODE_REVISION(version)
JSON_HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_MSVC_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_INTEL_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_PGI_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_ARM_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_IBM_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_CL430_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_CRAY_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_IAR_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_TINYC_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_DMC_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_PELLES_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch)
JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch)
JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute)
JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch)
JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch)
JSON_HEDLEY_HAS_BUILTIN(builtin)
JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch)
JSON_HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch)
JSON_HEDLEY_HAS_FEATURE(feature)
JSON_HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch)
JSON_HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch)
JSON_HEDLEY_HAS_EXTENSION(extension)
JSON_HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch)
JSON_HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch)
JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch)
JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch)
JSON_HEDLEY_HAS_WARNING(warning)
JSON_HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch)
JSON_HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch)
JSON_HEDLEY_PRAGMA(value)
JSON_HEDLEY_DIAGNOSTIC_PUSH
JSON_HEDLEY_DIAGNOSTIC_POP
JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x)
JSON_HEDLEY_CONST_CAST(T, expr)
JSON_HEDLEY_REINTERPRET_CAST(T, expr)
JSON_HEDLEY_STATIC_CAST(T, expr)
JSON_HEDLEY_CPP_CAST(T, expr)
JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
JSON_HEDLEY_DEPRECATED(since)
JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
JSON_HEDLEY_UNAVAILABLE(available_since)
JSON_HEDLEY_WARN_UNUSED_RESULT
JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
JSON_HEDLEY_SENTINEL(position)
JSON_HEDLEY_NO_RETURN
JSON_HEDLEY_NO_ESCAPE
JSON_HEDLEY_ASSUME(expr)
JSON_HEDLEY_UNREACHABLE_RETURN(value)
JSON_HEDLEY_UNREACHABLE()
JSON_HEDLEY_NON_NULL(...)
JSON_HEDLEY_PRINTF_FORMAT(string_idx, first_to_check)
JSON_HEDLEY_CONSTEXPR
JSON_HEDLEY_PREDICT(expr, expected, probability)
JSON_HEDLEY_PREDICT_TRUE(expr, probability)
JSON_HEDLEY_PREDICT_FALSE(expr, probability)
JSON_HEDLEY_LIKELY(expr)
JSON_HEDLEY_UNLIKELY(expr)
JSON_HEDLEY_UNPREDICTABLE(expr)
JSON_HEDLEY_MALLOC
JSON_HEDLEY_PURE
JSON_HEDLEY_CONST
JSON_HEDLEY_RESTRICT
JSON_HEDLEY_INLINE
JSON_HEDLEY_ALWAYS_INLINE
JSON_HEDLEY_NEVER_INLINE
JSON_HEDLEY_PRIVATE
JSON_HEDLEY_PUBLIC
JSON_HEDLEY_IMPORT
JSON_HEDLEY_NO_THROW
JSON_HEDLEY_FALL_THROUGH
JSON_HEDLEY_RETURNS_NON_NULL
JSON_HEDLEY_ARRAY_PARAM(name)
JSON_HEDLEY_IS_CONSTANT(expr)
JSON_HEDLEY_REQUIRE_CONSTEXPR(expr)
JSON_HEDLEY_BEGIN_C_DECLS
JSON_HEDLEY_END_C_DECLS
JSON_HEDLEY_C_DECL
JSON_HEDLEY_STATIC_ASSERT(expr, message)
JSON_HEDLEY_NULL
JSON_HEDLEY_MESSAGE(msg)
JSON_HEDLEY_WARNING(msg)
JSON_HEDLEY_REQUIRE(expr)
JSON_HEDLEY_REQUIRE_MSG(expr, msg)
JSON_HEDLEY_FLAGS
JSON_HEDLEY_FLAGS_CAST(T, expr)
JSON_HEDLEY_EMPTY_BASES
JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch)
JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute)
JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute)
JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin)
JSON_HEDLEY_CLANG_HAS_FEATURE(feature)
JSON_HEDLEY_CLANG_HAS_EXTENSION(extension)
JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute)
JSON_HEDLEY_CLANG_HAS_WARNING(warning)
JSON_HAS_CPP_11
JSON_HAS_EXPERIMENTAL_FILESYSTEM
JSON_HAS_FILESYSTEM
JSON_HAS_THREE_WAY_COMPARISON
JSON_HAS_RANGES
JSON_HAS_STATIC_RTTI
JSON_INLINE_VARIABLE
JSON_NO_UNIQUE_ADDRESS
JSON_THROW(exception)
JSON_TRY
JSON_CATCH(exception)
JSON_INTERNAL_CATCH(exception)
JSON_ASSERT(x)
JSON_PRIVATE_UNLESS_TESTED
NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...)

macro to briefly define a mapping between an enum and JSON

Since

version 3.4.0

NLOHMANN_BASIC_JSON_TPL_DECLARATION
NLOHMANN_BASIC_JSON_TPL
NLOHMANN_JSON_EXPAND(x)
NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME, ...)
NLOHMANN_JSON_PASTE(...)
NLOHMANN_JSON_PASTE2(func, v1)
NLOHMANN_JSON_PASTE3(func, v1, v2)
NLOHMANN_JSON_PASTE4(func, v1, v2, v3)
NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4)
NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5)
NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6)
NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7)
NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8)
NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9)
NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)
NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
NLOHMANN_JSON_TO(v1)
NLOHMANN_JSON_FROM(v1)
NLOHMANN_JSON_FROM_WITH_DEFAULT(v1)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...)

macro

Since

version 3.9.0

NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...)
NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...)

macro

Since

version 3.9.0

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...)
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
JSON_USE_IMPLICIT_CONVERSIONS
JSON_EXPLICIT
JSON_DISABLE_ENUM_SERIALIZATION
JSON_USE_GLOBAL_UDLS
INCLUDE_NLOHMANN_JSON_FWD_HPP_
JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_

Typedefs

using json = basic_json<>

default specialization

using ordered_json = basic_json<nlohmann::ordered_map>

specialization that maintains the insertion order of object keys

Functions

NLOHMANN_JSON_NAMESPACE_END NLOHMANN_JSON_NAMESPACE_BEGIN NLOHMANN_CAN_CALL_STD_FUNC_IMPL (begin)
NLOHMANN_JSON_NAMESPACE_END NLOHMANN_JSON_NAMESPACE_BEGIN NLOHMANN_CAN_CALL_STD_FUNC_IMPL (end)
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
inline bool operator==(const json_pointer<RefStringTypeLhs> &lhs, const json_pointer<RefStringTypeRhs> &rhs) noexcept

template<typename RefStringTypeLhs, typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
inline bool operator==(const json_pointer<RefStringTypeLhs> &lhs, const StringType &rhs)

template<typename RefStringTypeRhs, typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
inline bool operator==(const StringType &lhs, const json_pointer<RefStringTypeRhs> &rhs)

template<typename RefStringTypeLhs, typename RefStringTypeRhs>
inline bool operator!=(const json_pointer<RefStringTypeLhs> &lhs, const json_pointer<RefStringTypeRhs> &rhs) noexcept

template<typename RefStringTypeLhs, typename StringType = typename json_pointer<RefStringTypeLhs>::string_t>
inline bool operator!=(const json_pointer<RefStringTypeLhs> &lhs, const StringType &rhs)

template<typename RefStringTypeRhs, typename StringType = typename json_pointer<RefStringTypeRhs>::string_t>
inline bool operator!=(const StringType &lhs, const json_pointer<RefStringTypeRhs> &rhs)

template<typename RefStringTypeLhs, typename RefStringTypeRhs>
inline bool operator<(const json_pointer<RefStringTypeLhs> &lhs, const json_pointer<RefStringTypeRhs> &rhs) noexcept
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string (const NLOHMANN_BASIC_JSON_TPL &j)

user-defined to_string function for JSON values

file json_fwd.hpp
#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <vector>

Defines

NLOHMANN_JSON_VERSION_MAJOR
NLOHMANN_JSON_VERSION_MINOR
NLOHMANN_JSON_VERSION_PATCH
JSON_DIAGNOSTICS
JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
NLOHMANN_JSON_NAMESPACE_NO_VERSION
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b)
NLOHMANN_JSON_ABI_TAGS
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch)
NLOHMANN_JSON_NAMESPACE_VERSION
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
NLOHMANN_JSON_NAMESPACE_CONCAT(a, b)
NLOHMANN_JSON_NAMESPACE
NLOHMANN_JSON_NAMESPACE_BEGIN
NLOHMANN_JSON_NAMESPACE_END

Typedefs

using json = basic_json<>

default specialization

using ordered_json = basic_json<nlohmann::ordered_map>

specialization that maintains the insertion order of object keys

file quadrotor.h
#include “rlenvs/rlenvs_types_v2.h
file rlenvs_consts.h
#include “rlenvs/rlenvs_types_v2.h
#include <string>
file rlenvs_types_v2.h
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Dense>
#include <string>
#include <cstddef>
#include <vector>
file rlenvscpp_config.h

Defines

RLENVSCPP_DEBUG
file rlenvscpp_version.h

Defines

RLENVSCPP_VERSION_MAJOR
RLENVSCPP_VERSION_MINOR
RLENVSCPP_VERSION_PATCH
RLENVSCPP_VERSION
file bounding_box_type.h
file generic_line.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include <cmath>
#include <stdexcept>
file geom_point.h
#include “rlenvs/rlenvs_types_v2.h
#include <vector>
#include <array>
#include <cmath>
#include <ostream>
#include <algorithm>
#include <string>
file circle.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include <cmath>
file csv_file_reader.cpp
#include “rlenvs/rlenvs_types_v2.h
#include <boost/algorithm/string.hpp>
file csv_file_reader.h
#include “rlenvs/rlenvs_types_v2.h
#include <boost/noncopyable.hpp>
#include <string>
#include <vector>
#include <fstream>
file csv_file_writer.cpp
file csv_file_writer.h
#include “rlenvs/rlenvs_types_v2.h
#include <vector>
#include <tuple>
#include <initializer_list>
file file_formats.cpp
file file_formats.h
#include <string>
file file_handler_base.h
#include “boost/noncopyable.hpp”
#include <string>
file file_reader_base.cpp
file file_reader_base.h
#include “rlenvs/rlenvs_types_v2.h
#include “boost/noncopyable.hpp”
#include <string>
#include <fstream>
file file_writer_base.cpp
#include <boost/algorithm/string.hpp>
#include <chrono>
#include <ctime>
#include <stdexcept>
file file_writer_base.h
#include “boost/noncopyable.hpp”
#include <fstream>
#include <string>
file io_utils.h
#include <ostream>
#include <vector>
file json_file_reader.cpp
file json_file_reader.h
#include “rlenvs/rlenvs_types_v2.h
file tensorboard_server.cpp
#include “rlenvs/rlenvs_consts.h
#include <exception>
file tensorboard_server.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include <boost/noncopyable.hpp>
#include <string>
#include <string_view>
#include <unordered_map>
file iteration_counter.h
#include “rlenvs/rlenvs_types_v2.h
file iterative_algorithm_controller.cpp
file iterative_algorithm_controller.h
#include “rlenvs/rlenvs_types_v2.h
#include <limits>
file iterative_algorithm_result.cpp
file iterative_algorithm_result.h
#include “rlenvs/rlenvs_types_v2.h
#include <ostream>
#include <chrono>
#include <vector>
file math_utils.h
#include “rlenvs/rlenvs_types_v2.h
file normal_dist.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
#include <vector>
#include <random>
#include <cmath>
#include <numbers>
file std_map_utils.h
#include <any>
#include <map>
#include <stdexcept>
file line_segment_link.h
#include “rlenvs/rlenvs_consts.h
file waypoint.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
file waypoint_trajectory.h
#include “rlenvs/rlenvs_types_v2.h
#include <vector>
#include <utility>
#include <limits>
#include <type_traits>
file unit_converter.h
#include “rlenvs/rlenvs_types_v2.h
#include “rlenvs/rlenvs_consts.h
page todo

Class rlenvscpp::utils::io::FileHandlerBase< HandlerType >

write docs

Class rlenvscpp::utils::io::FileReaderBase

write docs

Class rlenvscpp::utils::io::JSONFileReader

write docs

page deprecated

Member basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::operator<<  (basic_json &j, std::istream &i)

This stream operator is deprecated since 3.0.0 and will be removed in version 4.0.0 of the library. Please use operator>>(std::istream&, basic_json&) instead; that is, replace calls like j << i; with i >> j;.

Member basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType, CustomBaseClass >::sax_parse  (detail::span_input_adapter &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)

This function is deprecated since 3.8.0 and will be removed in version 4.0.0 of the library. Please use sax_parse(ptr, ptr + len) instead.

dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/api_server
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/gymnasium/classic_control
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/connect2
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/maths/statistics/distributions
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/dynamics
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/extern
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/gdrl
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/geometry
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/grid_world
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/gym_pybullet_drones
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/gymnasium
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/io
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/extern/nlohmann/json
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/maths
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/extern/nlohmann
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/rigid_bodies
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/geometry/shapes
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/maths/statistics
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/io/tensor_board_server
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/gymnasium/toy_text
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils/trajectory
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/utils
dir /home/alex/qi3/rlenvs_from_cpp/src/rlenvs/envs/gymnasium/classic_control/vector